Grow height of parent div that contains floating nested divs

后端 未结 6 363
春和景丽
春和景丽 2020-12-04 23:53

I can’t seem to auto-grow my parent div’s height based on its floating child divs. All the children are floating, to take up space horizontally, an

6条回答
  •  失恋的感觉
    2020-12-05 00:03

    If the parent container only has floating children, it will have no height. Adding the following CSS to the parent container should help:

    .parent {
        overflow:hidden;
        width: 100%;
    }
    

    Read this article for more: http://www.quirksmode.org/css/clearing.html.

提交回复
热议问题