[thelist] Width of Parent DIVs depending on Child DIV - yes and no?

Craig Cook craigcook at gmail.com
Fri Feb 16 04:50:36 CST 2007

On 2/15/07, Stefan Schwarzer <st.schwarzer at geois.de> wrote:

> But my problem is that the parent-DIV is set to 100%. And that my
> inner DIVs should be only as large as theirs contents are. But they
> are 100% too...

Div is a block-level element, and as such will always occupy the full
available width (ie, 100%) unless some other width is specified. If
the element is floated left or right it will "shrinkwrap" to the width
of its contents, but floating boxes willy-nilly can bring about a slew
of other layout problems (and IE5/Mac doesn't approve of floats
without widths, if that concerns you).

Without seeing your desired layout, my best suggestion would be to
float div 3 for the shrinkwrap effect, then give it clear:both to keep
other content from flowing upwards around it. You'll also need to
clear floats at the bottom of div 2 to prevent it collapsing.

Craig, www.focalcurve.com

More information about the thelist mailing list