IE Lists and Floats
October 21, 2004 6:50 PM
Subscribe
IE Lists and Floats
I've been playing around with lists and have run up against what I believe is one of IEs box model bugs. Every workaround I know of is useless. I've created a simplified example of what I am doing that contains only what is needed to get the lists to style properly in a standards compliant browser. In the actual layout they are contained in a center column. If you view this in Firefox or Mozilla and then in IE 6 you'll see the problem.
Example Can anyone figure out what is going on here?
posted by Grod to computers & internet (7 comments total)
Because of this, closing the first <li> takes the position down to the bottom of the floated <ul> that's inside it. Then when the second <ul>-in-<li> comes along we're already below the bottom of the float so the things stack vertically instead of horizontally.
To avoid this problem you could try floating the <li> directly instead of its child <ul>; then there would be no parent element to fool IE into clearing the inner float.
On an unrelated point, I'm not sure why you're floating the outer <ul>s. Setting 'clear' on an element whose ancestor is floating sounds like asking for trouble to me.
Finally, you've got elements that are floated but without a width. In CSS 2.1 this is allowed and means 'shrink-to-fit'; in CSS 2 it explicitly isn't. In any case, different browsers will behave different in the face of this.
You could set a width for the left float and leave the right bit unfloated with a left-margin of the same width. But if what you really want is shrink-to-fit column-like behaviour, you're really probably best off with a table.
posted by BobInce at 7:27 PM on October 21, 2004