I’m developing a web page that has an outer floated left column and a regular right column.
The right column then contains a list of items where each item has a floated left column and a regular right column.
My problem is when a list item’s right column isn’t tall enough, the next list item is indented to be to the right of the previous item’s left column.
Convoluted? Okay, well I’ve posted the basic layout online.
I then removed items from a sublist so that one list item’s right column isn’t tall enough.
Finally, I tried correcting the problem using clear:both. The problem is that this clears the very outer floating div.
Is there any way to clear a floated element without clearing another, outer floated element?
In addition to your
clear: bothstyle, add anoverflow: hiddenoroverflow: autostyle to.MainRightColto give it its own block formatting context:This prevents the
clear: bothfrom clearing the.MainLeftColfloat, becauseand the context which
.MainLeftCollives in isbody‘s (or the viewport’s, I’m not exactly sure), so that’s outside of.MainRightCol‘s and its.ListItemchildren’s, which you apply theclearto.See the updated demo.