473,594 Members | 2,756 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Floating DIVs and "carriage returns"

Hello,

Suppose I want to play with DIVs as if they were type characters. I have
a series of fixed-height (width is of no importance) blocks which must
follow one another from left to right, with a small margin between them.
This is easily done with the CSS float:left property.
But in this context, what is the proper way to do a Line Feed/Carriage
Return?
Take a look at the code below for example's sake. I have 8 DIVs and I
want to arrange them in 2 rows of 4.
DIVs on the same line are given class="d1" property to apply a left float.
I've given the 5th one class="d2" property (ie no float), and the 3
following DIVs are class="d1" again.
What do you think of this example ? Is it the right way to achieve what
I'm trying to do -- or do you know another? Can't there be issues with
margins that would prevent the "line break" to work OK?
In fact, I've tried this example in Firefox but my class="d2" element
simply doesn't show.

Thanks to those who'll take a look at the problem and to those who'll help!

Arnost
<html>
<head>
<title></title>
<style type="text/css">
<!--
div {height:24px; width:60px; background-color:#FF6666;
margin-right:1px; margin-bottom:1px;}
..d1 {float:left;}
..d2 {background-color:#CC3333;}
-->
</style>
</head>
<body>
<div class="d1"></div>
<div class="d1"></div>
<div class="d1"></div>
<div class="d1"></div>
<div class="d2"></div>
<div class="d1"></div>
<div class="d1"></div>
<div class="d1"></div>
</body>
</html>
Nov 3 '06 #1
2 3973
On 2006-11-03, Arnost Sobota <sa******@minef i.gouv.frwrote:
Hello,

Suppose I want to play with DIVs as if they were type characters. I have
a series of fixed-height (width is of no importance) blocks which must
follow one another from left to right, with a small margin between them.
This is easily done with the CSS float:left property.
But in this context, what is the proper way to do a Line Feed/Carriage
Return?
The clear property.
Take a look at the code below for example's sake. I have 8 DIVs and I
want to arrange them in 2 rows of 4.
Set both clear: left and float: left on the fifth one (.d2)
DIVs on the same line are given class="d1" property to apply a left float.
I've given the 5th one class="d2" property (ie no float), and the 3
following DIVs are class="d1" again.
What do you think of this example ? Is it the right way to achieve what
I'm trying to do -- or do you know another? Can't there be issues with
margins that would prevent the "line break" to work OK?
In fact, I've tried this example in Firefox but my class="d2" element
simply doesn't show.
It's behind the other ones. Because it's a block level box, it starts
right at the left of its container, and the floats originating in the
previous (anonymous) block box, its preceding sibling, overflow it.
><html>
<head>
<title></title>
<style type="text/css">
<!--
div {height:24px; width:60px; background-color:#FF6666;
margin-right:1px; margin-bottom:1px;}
.d1 {float:left;}
.d2 {background-color:#CC3333;}
-->
</style>
</head>
<body>
<div class="d1"></div>
<div class="d1"></div>
<div class="d1"></div>
<div class="d1"></div>
<div class="d2"></div>
<div class="d1"></div>
<div class="d1"></div>
<div class="d1"></div>
</body>
</html>
Nov 3 '06 #2
Thank you, Ben C, your explanations are pleasurably *clear* too!

Arnost
Nov 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
8223
by: build | last post by:
G'day All, I have a problem with this loop. There are a number of .txt files in 'myPath'. tmpFile = Dir(myPath & "\*.txt") 'PROCESS FOLDER Do Until tmpFile = "" <lottsa code> <too much to post> tmpFile = Dir
3
5274
by: comp.lang.php | last post by:
PHP 4.3.8 with UNIX with option --with-magic_mime echo mime_content_type('/images/myimage.png'); // RETURNS "text/plain" PHP 4.3.11 with UNIX with option --with-magic_mime echo mime_content_type('/images/myimgae.png'); // RETURNS "text/plain"
10
4699
by: comp.lang.php | last post by:
echo mime_content_type('/var/www/html/video/small.mov'); // 1.5mb Quicktime video returns "video/quicktime" echo mime_content_type('/var/www/html/video/huge.mov'); // 10.5mb Quicktime video returns "text/plain" Environment: PHP 5.0.4 - Windows XP --enable-mime-magic PHP 4.3.11 - Fedora Core 4 --enable-mime-magic
5
2854
by: Dan C Douglas | last post by:
I have just installed VS.NET 2003 on my computer. I have a project that I have been developing on VS.NET 2002. I haven't upgraded this project to VS.NET 2003 yet and I am still developing it in VS.NET 2002. When I am putting values from my SQLDataReader into labels and text boxes I am getting results such as 400.0000, or 25.90. For example... ? dr("CostsPerBin") returns
7
6890
by: Jim Carlock | last post by:
Does a SELECT element (listbox) need to be inside a FORM element? The code I'm playing with: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
59
4568
by: Pierre Quentel | last post by:
Hi all, In some program I was testing if a variable was a boolean, with this test : if v in My script didn't work in some cases and I eventually found that for v = 0 the test returned True So I changed my test for the obvious "if type(v) is bool", but I still find it confusing that "0 in " returns True
13
3217
by: Noa | last post by:
Hi I have a page that looks like that: <form name="kuku1" action ="anotherpage.html" > <input name="name"> <input name="kuku2"> </form> As far as i know, "getAttribute" should return a string value of an
9
10711
by: Klaus Johannes Rusch | last post by:
IE7 returns "unknown" instead of "undefined" when querying the type of an unknown property of an object, for example document.write(typeof window.missingproperty); Has "unknown" been defined as a valid return value for the typeof operator in a later version of ECMAScript or is this a JScript "feature"? -- Klaus Johannes Rusch
5
5707
by: yogeshmk | last post by:
I'm writing an application which is required to function with many languages and also compile on Linux & windows. Here's how I find the locale .. # include <stdio.h> # include <locale.h> int main(void) {
0
7946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7876
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8003
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5408
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3859
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3897
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1478
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1210
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.