Hi,
I had the following html code:
And this works as expected (expected by me that is!) in IE by floating all left boxes from the top on the left and all right boxes from the top on the right, independently of each other. However this does not work on Mozilla.Code:<html> <head> <style type="text/css"> #container{ width: 300px; } .left { float: left; clear: left; } .right{ float: right; clear: right; } </style> </head> <body> <div id="container"> <div class="left">Left Content</div> <div class="left">Left Content</div> <div class="left">Left Content</div> <div class="right">On the Right</div> <div class="right">On the Right</div> </div> </body> </html>
If I replace this with the following code:
Then I do in fact get what I want in both browsers but I found it odd that Mozilla would require more superfluous divs to get the layout to work. It also makes it a bit more unintuitive and awkward programmatically because now I have to gather, group and then print out the left and right types of divs . With the first layout (working only in IE) I could just mix these types of divs and print them out as they come out of the database for example with a simple loop, just attaching the right class to the right type.Code:<html> <head> <style type="text/css"> #container{ width: 300px; } .left { float: left; } .right{ float: right; } </style> </head> <body> <div id="container"> <div class="left"> <div>Left Content</div> <div>Left Content</div> <div>Left Content</div> </div> <div class="right"> <div>On the Right</div> <div>On the Right</div> </div> </div> </body> </html>
I have found a solution to my problem but would like to hear feedback for anyone who knows more about this. Is this a bug in one or the other browser? Which is the standards way and is there a reason behind it? Or is there a better solution to the one I found that would allow me to not group my divs in artificial container divs.
Thank you!






In the end the result is actually much less code than you used.

Bookmarks