Is there a way to achieve height:auto;
for a parent element even when child elements are using float:left;
or float:right
?
Solution for the Parent Element:
#parent {
width:100px;
height:auto;
padding-bottom:10px;
background:#0F0;
}
Child Element Floating Left:
#child_left {
width:50%;
height:50px;
float:left;
background:#00F;
}
Here is a fiddle demonstrating the issue: http://jsfiddle.net/27EWw/