When child divs are floated, parent divs lose auto-height

后端 未结 3 1330
借酒劲吻你
借酒劲吻你 2021-02-07 02:25

I have a parent div called main. It has a bunch of child divs in it, which I floated left or right.

When I finished floating the last one, the height of the main div com

相关标签:
3条回答
  • 2021-02-07 03:08

    Are you using relative positioning for your floats?

    You'll need to put a fake div in to "hold open" the parent div otherwise. As soon as everything is floated you will lose all basis for height in the parent div. (Nothing is in there.)

    0 讨论(0)
  • 2021-02-07 03:16

    inserting "overflow:hidden;" into parent div worked for me.

    0 讨论(0)
  • 2021-02-07 03:27

    Contain your floats.

    On the div called main add overflow:hidden;. That should contain it.

    0 讨论(0)
提交回复
热议问题