Grow height of parent div that contains floating nested divs

后端 未结 6 364
春和景丽
春和景丽 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:15

    Adding the overflow css property on the parent element will fix the issue (no need for an empty & ugly div element to clear the float) :

    .parentelement {
        overflow:auto;
        display: block;
        width: 100%;
    }
    

    I added the display and width properties because some browsers will need theses properties to be defined.

提交回复
热议问题