繁体   English   中英

Z索引堆叠顺序

[英]Z-index stacking order

考虑以下jsfiddle: http : //jsfiddle.net/dHaM8

HTML:

<div class="first"><img src="http://placekitten.com/g/200/300"/></div>
<div class="second"></div>
<div class="third"><p class="test"> test test test </p></div>

CSS:

.first img {position:fixed; top: 10; left: 10; z-index: 1}
.test {position:fixed; top: 10; left: 10; z-index: 10}
.first {
    background-color: #a6a6a6;
    height: 600px;
    background-attachment: fixed;
    background-image: url("http://placehold.it/1000x500");
}

.second {
    background-color: #fff;
    min-height: 500px;
    z-index:2;
    position:relative;
}

 .third {
    background-color: #ff0000;
    min-height: 500px;
    background-attachment: fixed;
    position:relative;
    z-index:3;
 }

我想做的是:

小猫应该保持在div“ first”内,如果您查看CSS,这已经实现了。

但是,第三个div中的文本未显示!

如果我将div设置为高于小猫的div,则文本将显示在我不想发生的第一个div中。 我只希望它显示在第三个div中。

请帮助。

给出位置:相对于<p>标记。 小提琴

.test {position:relative; top: 10px; left: 10px; z-index: 10}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM