开发者

Please explain overflow:hidden 's effect on backgrounds?

开发者 https://www.devze.com 2023-01-31 03:04 出处:网络
I know when your elements background 开发者_如何学Cis not behind all of its content, (eg: because of floated elements, positioned elements, margin) adding overflow:hidden fixes the issue, forcing the

I know when your elements background 开发者_如何学Cis not behind all of its content, (eg: because of floated elements, positioned elements, margin) adding overflow:hidden fixes the issue, forcing the background to show behind those elements.

For example see this question and meder's answer.

However, when doing this, it is not hiding any overflowing content, so how does setting this effect anything at all?

Basically I know it works, but I want to understand why?


It creates a new block formatting context, which clears the floats.

http://www.w3.org/TR/CSS2/visuren.html#block-formatting

And.. it does clip overflowing content: http://jsfiddle.net/rDmhn/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号