[thelist] [CSS] Uninherited background color with float

Tim Beadle tsb at wigner.ioppublishing.com
Mon Apr 19 06:06:21 CDT 2004


On Mon, Apr 19, 2004 at 11:56:34AM +0100, Adriano Castro wrote:
>     The 3 sections ("big top section", "small left section", "small rite
> section") are all contained under the "main" div. The last "small
> left" and "small rite" sections are floated to the left and rite,
> respectively.
> 
>     Why don't they inherit the #main's background color?

Floated elements have "zero" height. If you put a 1px border (just for testing)
around your floated divs, you'll see they take up no vertical space.

You need to "clear" before the end of the floated divs, by inserting
<div style="clear: both;">&nbsp;</div>.

See Eric Meyer's explanation of floats. It explains better than I can:
http://www.complexspiral.com/publications/containing-floats/

Tim
-- 
"I don't need a blogging tool or an aggregator or designer or ashtray or 
car stereo built into my web browser. I just need it to display web pages 
properly." -- Kevin Daly


More information about the thelist mailing list