| | |
Floats going above clears
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Feb 2009
Posts: 3
Reputation:
Solved Threads: 0
I have a web page that uses float: left and clear left to stack columns.
This page works fine on firefox but not on ie8.
Columns are like this:
xxx
12
34
xxx
56
78
90
Where each number or xxx represents a div. Odd numbers have float : left; clear: left;, and even number only have a float left;. The xxx represents another div with only clear: left;.
On ie8, however:
xxx
124
3
xxx
5680
7
9
Note that the divs are found in the code in the order of the first example. The float: left;'s are going about the cleared elements!
However, notice once we hit an xxx it is reset. Therefore I assume one way to fix it would be insert a blank div that is only clear: left;ed in front of the odd numbers. But I do not want to do this! Isn't there a sane way to accomplish this in both browsers?
I can post a url if necessary.
thanks,
chris
This page works fine on firefox but not on ie8.
Columns are like this:
xxx
12
34
xxx
56
78
90
Where each number or xxx represents a div. Odd numbers have float : left; clear: left;, and even number only have a float left;. The xxx represents another div with only clear: left;.
On ie8, however:
xxx
124
3
xxx
5680
7
9
Note that the divs are found in the code in the order of the first example. The float: left;'s are going about the cleared elements!
However, notice once we hit an xxx it is reset. Therefore I assume one way to fix it would be insert a blank div that is only clear: left;ed in front of the odd numbers. But I do not want to do this! Isn't there a sane way to accomplish this in both browsers?
I can post a url if necessary.
thanks,
chris
cj, have you tried adding a
clear: right property to the even numbered divs? and clear: both for the xxx. If you know ASP, you can save other daniweb members from idiots like me by helping out in this forum.
Visit this thread if your username starts with one of the following letters: B D F H J L N P R T X Y Z.
Visit this thread if your username starts with one of the following letters: B D F H J L N P R T X Y Z.
CJ,
Maybe you want something like this?
Floats are pretty rubbish for aligning numeric data.
Airshow
Maybe you want something like this?
HTML and CSS Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Airshow :: Untitled</title> <style type="text/css"> .oddEvenWrapper { width:150px; } .oddEvenWrapper h1 { margin:2px 0; font-size:12pt;; } .odd { float:left; clear:left; } .even { float:right; clear:right; } </style> </head> <body> <div class="oddEvenWrapper"> <div class="odd"><h1>Odds</h1></div> <div class="even"><h1>Evens</h1></div> <div class="even">124</div> <div class="odd">3</div> <div class="even">5680</div> <div class="odd">7</div> <div class="odd">9</div> <div class="odd">2009</div> </div> </body> </html>
float:left aligns the most significant digit while float:right aligns the least significant digit (which may or may not be to the right of the decimal point). The human eye likes alignment of the units column.Airshow
50% of the solution lies in accurately describing the problem!
•
•
•
•
CJ,
Floats are pretty rubbish for aligning numeric data.float:leftaligns the most significant digit whilefloat:rightaligns the least significant digit (which may or may not be to the right of the decimal point). The human eye likes alignment of the units column.
Airshow
If you know ASP, you can save other daniweb members from idiots like me by helping out in this forum.
Visit this thread if your username starts with one of the following letters: B D F H J L N P R T X Y Z.
Visit this thread if your username starts with one of the following letters: B D F H J L N P R T X Y Z.
![]() |
Similar Threads
- Three column div problems - breadcrumb bar and footer (HTML and CSS)
- mixing floats and ints...(don't ban me please for being such a noob) (C++)
- Rounding and displaying floats (C)
- help plz (C++)
- clears screen instead of scrolling. (Assembly)
- Login page refreshes and clears fields (ASP.NET)
- My own read function (C)
- getting text to float (HTML and CSS)
- Trouble parsing floats and integers (C++)
Other Threads in the HTML and CSS Forum
- Previous Thread: Within a <td>, how do I call a Javascript function on ANY event?
- Next Thread: Table row color altering based on conditions
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form format google griefers hackers hitcounter hover html ide ie7 ie8 iframe image images internet internetexplorer intranet iphone javascript jpeg layout macbook maps marketshare microsoft mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization perl pnginie6 positioning problem scroll seo shopping studio swf swf. textcolor timecolor titletags url urlseparatedwords visual visualization web webdevelopment webform website windows7 xml xsl





