Floats going above clears

Reply

Join Date: Feb 2009
Posts: 3
Reputation: cjmalloy is an unknown quantity at this point 
Solved Threads: 0
cjmalloy cjmalloy is offline Offline
Newbie Poster

Floats going above clears

 
0
  #1
Jul 7th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3
Reputation: cjmalloy is an unknown quantity at this point 
Solved Threads: 0
cjmalloy cjmalloy is offline Offline
Newbie Poster

Re: Floats going above clears

 
0
  #2
Jul 8th, 2009
I can confirm adding the empty divs fixes the problem, and I can also confirm it looks stupid.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 23
Reputation: FeralReason is an unknown quantity at this point 
Solved Threads: 0
FeralReason FeralReason is offline Offline
Newbie Poster

Re: Floats going above clears

 
0
  #3
Jul 8th, 2009
Can you either post some code or a URL ? Would make it easier for me to understand what you are describing.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 276
Reputation: kanaku is on a distinguished road 
Solved Threads: 15
kanaku's Avatar
kanaku kanaku is offline Offline
Posting Whiz in Training

Re: Floats going above clears

 
0
  #4
Jul 11th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 857
Reputation: Airshow is on a distinguished road 
Solved Threads: 122
Airshow's Avatar
Airshow Airshow is offline Offline
Practically a Posting Shark

Re: Floats going above clears

 
0
  #5
Jul 13th, 2009
CJ,

Maybe you want something like this?

HTML and CSS Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html>
  3. <head>
  4. <title>Airshow :: Untitled</title>
  5. <style type="text/css">
  6. .oddEvenWrapper { width:150px; }
  7. .oddEvenWrapper h1 { margin:2px 0; font-size:12pt;; }
  8. .odd { float:left; clear:left; }
  9. .even { float:right; clear:right; }
  10. </style>
  11. </head>
  12.  
  13. <body>
  14.  
  15. <div class="oddEvenWrapper">
  16. <div class="odd"><h1>Odds</h1></div>
  17. <div class="even"><h1>Evens</h1></div>
  18.  
  19. <div class="even">124</div>
  20. <div class="odd">3</div>
  21. <div class="even">5680</div>
  22. <div class="odd">7</div>
  23. <div class="odd">9</div>
  24. <div class="odd">2009</div>
  25. </div>
  26.  
  27. </body>
  28. </html>
Floats are pretty rubbish for aligning numeric data. 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!
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 276
Reputation: kanaku is on a distinguished road 
Solved Threads: 15
kanaku's Avatar
kanaku kanaku is offline Offline
Posting Whiz in Training

Re: Floats going above clears

 
0
  #6
Jul 14th, 2009
Originally Posted by Airshow View Post
CJ,

Floats are pretty rubbish for aligning numeric data. 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
He isn't looking for a way to place significant digits (or at least, he didn't say it in his post). Just a way to align the divs properly. He used the odd-even numbering to show that each row should have 2 divs, and that the 'odd' numbered divs (or the first ones in the row) should align to the left, while the even numbered divs should sit next to the odd divs. And that no extra 'third' div should share their row. =)
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 857
Reputation: Airshow is on a distinguished road 
Solved Threads: 122
Airshow's Avatar
Airshow Airshow is offline Offline
Practically a Posting Shark

Re: Floats going above clears

 
0
  #7
Jul 14th, 2009
Kanaku,

You clearly understand the OP's problem better than I.

Airshow
50% of the solution lies in accurately describing the problem!
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 30
Reputation: dipak_passion is an unknown quantity at this point 
Solved Threads: 1
dipak_passion's Avatar
dipak_passion dipak_passion is offline Offline
Light Poster

Re: Floats going above clears

 
0
  #8
Jul 15th, 2009
Ok, please post the URL. It will help best here.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC