【发布时间】:2014-04-06 19:44:32
【问题描述】:
当页面中有一些absolute DIV 和一个fixed DIV 作为z-index 大于absolute DIV 的absolute DIV 之一的孩子时,fixed DIV 落后absolute DIV!
像这样:http://jsfiddle.net/3qRaR/1/
HTML:
<div class='l1'>
<div class='data'></div>
</div>
<div class='l1'>
<div class='data'></div>
</div>
<div class='l1'>
<div class='data'></div>
</div>
<div class='l1'>
<div class='data'></div>
</div>
CSS:
.l1{
display: block;
width: 100px;
height: 100px;
background-color: yellow;
z-index:1001;
margin: 5px;
position: absolute;
}
.l1:nth-child(1){
left: 5px;
top: 5px;
}
.l1:nth-child(2){
left: 110px;
top: 5px;
}
.l1:nth-child(3){
left: 220px;
top: 5px;
}
.l1:nth-child(4){
left: 330px;
top: 5px;
}
.data{
display:none;
position: fixed;
left:0px;
top:0px;
right:0px;
bottom:0px;
z-index:2000;
background: black;
}
.l1:first-child .data{
display: block;
}
为什么?
我怎样才能让它走到他们的前面?
谢谢
【问题讨论】:
-
您的标记有缺陷。
fixed(相对于窗口)inside 一个元素是absolute(相对于文档),你怎么能拥有它?如果你想把它放在前面,把它移到父容器的外面。 -
@cale_b: 我要临时最大化另一个 div 中的一个 div 以将整个页面填充为全屏视图
-
再说一次,这不是你应该怎么做。
-
然后使用绝对定位。未修复。
-
@cale_b: 绝对位置导致填充父 DIV 但我不想填充父;我想填满页面(即视口)!