Home › Forums › CSS › CSS Divs Not Adjusting for Body Content › Re: CSS Divs Not Adjusting for Body Content
March 6, 2012 at 9:26 pm
#98308
Member
That is due to you floating the image to the right. Floated elements are removed from the normal flow of the document, meaning that parent elements won’t naturally expand to contain them.
Firstly, rather than using HTML attributes to set height/width and so on, use CSS. Secondly, to get the parent element to contain the floated image you will need to use a clearfix of some sort. Here is one I like to use:
.cf:after,
.cf:before {
content: '';
display: table;
}
.cf:after {
clear: both;
}
.cf {
zoom: 1;
}