当子元素浮动时无法撑开父元素,父元素高度为0。这时可以通过在浮动的子元素后清除浮动来使父元素获得正确的高度。

<div>
    <div style="float:left;height:200px;">child</div>
    <div style="clear:both;"></div>
</div>

  

相关文章:

  • 2022-12-23
  • 2021-10-22
  • 2022-12-23
  • 2021-11-09
  • 2022-01-30
  • 2021-09-13
  • 2022-12-23
  • 2021-06-10
猜你喜欢
  • 2022-12-23
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
相关资源
相似解决方案