當子元素浮動時沒法撐開父元素,父元素高度爲0。這時能夠經過在浮動的子元素後清除浮動來使父元素得到正確的高度。html
<div> <div style="float:left;height:200px;">child</div> <div style="clear:both;"></div> </div>