Floating image to the left changes container div's height

前端 未结 2 377
萌比男神i
萌比男神i 2021-01-01 23:25

When I try to run the following:

//This is a 200x200 image
相关标签:
2条回答
  • 2021-01-01 23:52

    Add overflow:auto; to #container

    (Explanations below)

    0 讨论(0)
  • 2021-01-02 00:08

    You need to add a clearing div after the img:

    ​<div id="container">
         //This is a 200x200 image        
         <img src="http://dummyimage.com/200x200/CCC/000" />
         <div class="clearing"></div>
    </div>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
    

    And in CSS:

    .clearing { clear: both; }
    
    0 讨论(0)
提交回复
热议问题