Why overflow:hidden expands parent element (containing floated child elements)?

前端 未结 2 1296
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-09 14:13

In short:
Basically, I just want to know why overfow:hidden explands the container containing a floated item. Shouldnt it hide the overflowing element like in this image

2条回答
  •  旧巷少年郎
    2021-02-09 14:51

    This is a really good question despite others' comments.

    The actual answer is "because someone decided it should work that way."

    Fortunately, we can discuss the topic online, maybe influence those people, and sometimes even change things.

    In the meantime you can always read "Why Containers Don’t Clear Themselves": http://css-tricks.com/containers-dont-clear-floats/

提交回复
热议问题