Skip to content Skip to sidebar Skip to footer

Height Of A Div

Height of a div I'm trying to set the size of a div according to its content. See the complete code here. Basically my problem is in the div: content In the HTML code look for the

Solution 1:

Add a "overflow:hidden;" to the div#content so it will look like the following. You won't need a separate clear property and a p tag. Good luck :)

div#content
{
    margin:auto 40px;
    width:200;
    border:2px solid red;
    overflow:hidden;

}

Solution 2:

To make a container expand to fill floated elements, give it an overflow property:

div.wrapper {
    overflow: auto;
}

Solution 3:

A better method than using an empty <div class="clear"> is to use the 'cearfix' method.

This is an example borrowed straight from HTML5Bolierplate , just apply it to the div that is giving you trouble.

In your case #content will become #content.clearfix

/* The Magnificent Clearfix: Updated to prevent margin-collapsing on child elements.
   j.mp/bestclearfix */.clearfix:before, .clearfix:after { content: "\0020"; display: block; height: 0; overflow: hidden; }
.clearfix:after { clear: both; }
/* Fix clearfix: blueprintcss.lighthouseapp.com/projects/15318/tickets/5-extra-margin-padding-bottom-of-page */.clearfix { zoom: 1; 

Post a Comment for "Height Of A Div"