在一个相对定位的div#out中,有一个绝对定位的div#in。div#in被拉出了文档流,并通过将top、bottom、left和right坐标设置为0而覆盖div#out。虽然这样没问题,但我不明白的是,如果我给div#sibling设定position:relative,它会出现在div#in上方。
我已经检查了所有div元素的z-index属性,它们都是"auto",即相当于0。
我使用的版本是Version 45.0.2454.101 Ubuntu 14.04 (64-bit),但我认为这只是我的误解,而不是浏览器的问题。
非常感谢您的帮助。
我已经检查了所有div元素的z-index属性,它们都是"auto",即相当于0。
我使用的版本是Version 45.0.2454.101 Ubuntu 14.04 (64-bit),但我认为这只是我的误解,而不是浏览器的问题。
非常感谢您的帮助。
<style>
#out {
border: 1px solid red;
background: red;
position: relative;
}
#in {
border: 1px solid green;
background: green;
position: absolute;
top:0;
right:0;
bottom: 0;
left: 0;
}
#sibling{
position:relative;
}
</style>
<div id="out">
This is the outer div<br>
position relative
<div id="in">inner div position absolute</div>
<div id="other">other div position static </div>
<div id="sibling">sibling position relative </div>
</div>