csshtmlouter-joinstretched

Outer Div will not stretch to fit inner div (using clear)


I've been reading about how elements with the float attribute do not have their height accounted for. Therefore, I should use clear:both right before the end of the parent div so that it will stretch over the entire inner div.

You can see on This Page that the div with the id full-height-template-container is not stretching over its inner content, and therefore the footer (copyright text on the bottom right) is coming up too high on the page.

The layout looks like this:

<div id="full-height-template-containter">
  <div id="content-container">
    <div id="full-width" style="float:left;"> 
    </div>
    <div style="clear:both;"></div>
  </div>
<div style="clear:both;"></div>
</div>

What else can I try in order to make the outer div stretch over its children?

Thanks in advance!


Solution

  • In #full-height-template-container you are using height: 100% which means the div takes 100% height of the parent.

    If we track back in your CSS each parent element is assigned height: 100%, including the html and body elements, which means that the height is taken from the window - so as a result the div will never exceed the size of the window (but content will still overflow).

    So it is not the floats that are causing the problem, it is the height you are explicitly assigning to each div.