CSS container div not getting height

后端 未结 6 542
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 17:13

I want my container div to get the height of max of its children\'s height. without knowing what height the child divs are going to have. I was trying out on JS

6条回答
  •  暖寄归人
    2020-11-30 17:43

    You are floating the children which means they "float" in front of the container. In order to take the correct height, you must "clear" the float

    The div style="clear: both" clears the floating an gives the correct height to the container. see http://css.maxdesign.com.au/floatutorial/clear.htm for more info on floats.

    eg.

    World

提交回复
热议问题