posted May 15, 2008  

Ever notice the weird difference in margins between IE6 and the rest of the browsers when using floats? IE6 seems to like to add an extra pixel more than specified in margins. The following will show you an easy way to fix this problem.

The following two floated divs should appear on the same line in all browsers other than IE6.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed nulla elit, luctus a, aliquet ac, porta quis, nulla.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed nulla elit, luctus a, aliquet ac, porta quis, nulla.

One way to fix this is to include another stylesheet for IE6 using the IE6 conditional or the *html hack with a margin declaration of 1px less than specified for the floated element. This way can be a little to bothersome however.

There is an even simpler way to fix this. Simply add:

display:inline

to the floated element. That’s it!

Here are the same two divs, but this time, with display:inline.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed nulla elit, luctus a, aliquet ac, porta quis, nulla.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed nulla elit, luctus a, aliquet ac, porta quis, nulla.
filed under: ie solutions, layouts

tags: , ,


comments:
no comments yet.
leave a comment:
Copyright © 2008-2009 csswoes.com • Bryan Duran • All Rights Reserved