Wrapper div height is 0 with floated elements inside

前端 未结 3 411
挽巷
挽巷 2020-12-14 19:41

I have a wrapper

which contains two inner
s that are floating.

相关标签:
3条回答
  • 2020-12-14 20:15

    Try this:

    <div class="outside" style="border:1px solid #555; overflow:auto">
    <div class="inside" style="float:left; width:40px;">CONTENT</div>
    <div class="inside2" style="float:left; width:40px;">CONTENT</div>
    </div>//Outside container close
    
    0 讨论(0)
  • 2020-12-14 20:18

    Set overflow: hidden on the parent.

    <div class="outside" style="border:1px solid #555;overflow:hidden;">
      <div class="inside" style="float:left; width:40px;">CONTENT</div>
      <div class="inside2" style="float:left; width:40px;">CONTENT</div>
    </div>
    
    0 讨论(0)
  • 2020-12-14 20:25

    The outer div is collapsing because the two child divs inside of it are floating. The easiest fix for this is to set overflow: hidden; on the outer div.

    0 讨论(0)
提交回复
热议问题