如何让孩子(位置:固定)低于父母(“位置:固定”)?

时间:2013-12-11 13:57:35

标签: html css

如何将子元素(position:fixed)放在父元素下面(position:fixed)。我尝试给子元素提供一个比父元素的z-index值更低的z-index。但它仍然在父元素之上。我不能使用较低的z-index使其显示在父级下方吗?

我该怎么办?

2 个答案:

答案 0 :(得分:0)

据我所知,z-index位于父级内部,因此子对象不能位于其父级之下。

答案 1 :(得分:0)

http://jsfiddle.net/VD9Dv/。两种不同的div组合将向您展示差异。

HTML

<div class="parent">
        <div class="child"></div>
    </div>  

    <div class="parent positioned">   
    </div>
     <div class="child positioned"></div>

CSS:

.parent{width:200px;height:200px;background:#ccc;
 position:fixed;z-index:100;padding:15px}
.child{width:100px;height:100px;background:#eeffcc;
 position:fixed;z-index:-90}

.positioned{
    left: 240px;
}
相关问题