Why block div not get height auto?

This question already has an answer here:

  • How do you keep parents of floated elements from collapsing? [duplicate] 16 answers

  • You need to add the following rule

    .ForTags { overflow: auto }
    

    to create a block formatting context for the parent block that contains the floating elements.


    The PopularTags are floated which means they do not count as content for the containing element when calculating it's height. You will need to add an element after the floated elements with a style of clear: both; which will fix it.

    Additional HTML after the last PopularTags element

    <div class="clearfix"></div>
    

    Additional CSS

    .clearfix { clear: both; }
    

    More information about clearing floats and other solutions can be found here: http://www.quirksmode.org/css/clearing.html

    链接地址: http://www.djcxy.com/p/88432.html

    上一篇: 在另一个div中包含一个div

    下一篇: 为什么阻止div没有获得高度自动?