471,599 Members | 920 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,599 software developers and data experts.

Nested floated divs

Hi

If I have a container div and inside the container div I float two divs
(one left and one right), the containting div will collapse as the
floated divs will no longer prop it up, meaning that any background
colour or image on the containing div will not be visible.

Now, suppose I put left and right padding on the containing div. How
come, if the containing div has collapsed, does the padding of the
container still apply to the two nested floated divs? It seems as though
the floated divs are 'inside' the container in some ways, but not inside
the container in other ways (they don't prop it up). Is there some
simple way to think of this so it all makes sense?
Oct 7 '07 #1
2 2068
On 2007-10-07, Ben C. <be*@example.netwrote:
Hi

If I have a container div and inside the container div I float two divs
(one left and one right), the containting div will collapse as the
floated divs will no longer prop it up, meaning that any background
colour or image on the containing div will not be visible.

Now, suppose I put left and right padding on the containing div. How
come, if the containing div has collapsed, does the padding of the
container still apply to the two nested floated divs?
The container still has all its padding. Its top, left and right padding
will be above, to the left and to the right of the floats inside.

It's just that its auto height calculation (if it has auto height)
doesn't take account of the floats.
It seems as though the floated divs are 'inside' the container in some
ways, but not inside the container in other ways (they don't prop it
up). Is there some simple way to think of this so it all makes sense?
The explanation you've given is OK-- they start inside but end outside.
Oct 7 '07 #2
In article <5m************@mid.individual.net>,
"Ben C." <be*@example.netwrote:
Hi

If I have a container div and inside the container div I float two divs
(one left and one right), the containting div will collapse as the
floated divs will no longer prop it up, meaning that any background
colour or image on the containing div will not be visible.

Now, suppose I put left and right padding on the containing div. How
come, if the containing div has collapsed, does the padding of the
container still apply to the two nested floated divs? It seems as though
the floated divs are 'inside' the container in some ways, but not inside
the container in other ways (they don't prop it up). Is there some
simple way to think of this so it all makes sense?
Well you could think of it this way:

<http://tinyurl.com/2wktfv>

--
dorayme
Oct 8 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Zaka Ferenc | last post: by
9 posts views Thread by Dustin | last post: by
7 posts views Thread by Gnolen | last post: by
1 post views Thread by alex | last post: by
4 posts views Thread by D | last post: by
7 posts views Thread by Ed Jay | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.