静影沉璧番外:Absolutely positioned boxes show outside their parent container styled with overflow:hidden

来源:百度文库 编辑:九乡新闻网 时间:2024/05/06 14:56:15

overflow:hidden and absolutely positioned elements

Markup

box 1
box 2
box 3
box 4

If this wrapper was positioned (any value other thanstatic), then it would become the positioning block and the four nestedboxes would position themselves in relation to its layout. They wouldalso be clipped outside of the positioning block boundaries.

CSS

#wrapper {overflow:hidden;zoom:1;}.box1,.box2,.box3,.box4 {position:absolute;background:#fff;}.box1 {left:0;top:0;}.box2 {right:0;top:0;}.box3 {left:0;bottom:0;}.box4 {right:0;bottom:0;}