Forum How do I...?

Floating next to a variable width element

marimbus
I have a div that is usually 100% width, containing only text with a light background color. When I float an element alongside it, the text wraps around the float but the div itself doesn't respect the wrap, and runs behind the floated element. I've tried overflow:hidden, but that doesn't seem to work. Is there a way to get the div to restrict its width when an element is floated next to it?

Great product. I'm really enjoying it. Thanks in advance.
mikeday
That's how blocks are supposed to work: they don't get pushed aside by floats, but their content does. You could try using a table or inline-block instead, these will get pushed aside, or pushed down, depending on the available space.
marimbus
Thanks for the information. I found a workaround using the adjacent sibling selector. I told my variable width element that it needed to be a certain width when following my floated element.
mikeday
Ah, good solution. :)