Grow height of parent div that contains floating nested divs

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

    You need to apply clearfix to the parent as floats are removed from the flow of the document an don't automatically add any height to the parent's contents. Clearfix instructs teh parent to extend to a height tall enough to clear its last floated child. This method is well established and works across browsers.

提交回复
热议问题