Float Creates Overlapping Divs

前端 未结 5 608
小鲜肉
小鲜肉 2021-02-05 20:43

I have two divs (one inside of the other) and am running into a bit of a problem when I float the one inside to \"left\". The problem is that the outer div doesn\'t expand its

5条回答
  •  猫巷女王i
    2021-02-05 21:21

    While the solutions above should work, I figure it's worth pointing out that there's one magical trick I haven't seen considered yet (in this thread).

    Just float #div1 left. When you float the parent element, it'll automagically clear the child element - fairly useful, really. You could build an entire layout of floated stacks, and then have one final clear at the end, and it'd be fairly reliable.

提交回复
热议问题