Reputation: 5025
<div id="wrapper" style="background:red;">
<div id="child" style="height:500px;float:left;"></div>
</div>
How can I make #wrapper
stretch with the height of #child
?
Upvotes: 0
Views: 70
Reputation: 8930
Add a clearfix class to the parent div. Here is the CSS: Fiddle
.cf { zoom: 1; }
.cf:before, .cf:after { content: ""; display: table; }
.cf:after { clear: both; }
Upvotes: 1
Reputation: 559
you have to clear the float via clear:both, so that the wrapper box knows the end.
<div id="wrapper" style="background:red;">
<div id="child" style="height:500px;float:left;"></div>
<div style="clear:both;"></div>
</div>
Upvotes: 2
Reputation: 3084
give the parent a height: 0px auto; the initial height in px is what you want it to start at and auto will allow this to adjust based on the height of its children
Upvotes: 0