参见英文答案 >
Why doesn’t the height of a container element increase if it contains floated elements?7个
inner1和inner2 div在外部div中,外部高度仍然为0px,height为auto
inner1和inner2 div在外部div中,外部高度仍然为0px,height为auto
如何获得外部div的子元素的高度?
码
<style> #outer { width:300px; height:auto;; background:#ccc; } #inner1 { float:left; width:100px; height:100px; background:#f00; } #inner2 { float:left; width:100px; height:100px; background:#0f0; } </style> <div id="outer"> <div id="inner1"></div> <div id="inner2"></div> </div>