我需要放置一个背景图像(#前台)在网站的全球背景(@包装)之上。问题是包装器的背景显示在前台的顶部,尽管包装器的z索引和前景较低。
HTML:
<body>
<div id="wrapper">
//website content here
</div>
<div id="foreground"></div>
</body>CSS
#wrapper {
width:100%;
background:url(../img/header/main_bg01.jpg) repeat-x top center, url(../img/header/patternextra.jpg) repeat top center;
min-height:1650px;
overflow:hidden;
z-index: -2;
}
#foreground {
background: url(../img/foreground.png) repeat 90% 110%;
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
z-index: -1;
}致以敬意,
发布于 2014-11-26 14:46:56
Z-索引在没有指定位置的情况下无法工作。
尝试:
#wrapper {
width:100%;
background:url(../img/header/main_bg01.jpg) repeat-x top center, url(../img/header/patternextra.jpg) repeat top center;
min-height:1650px;
overflow:hidden;
z-index: -2;
position: relative;
}发布于 2014-11-26 14:46:58
将z-索引更改为正值:
#wrapper {
z-index: 1;
}
#foreground {
z-index: 2;
}为我工作:http://jsfiddle.net/jaakkokarhu/4y37zkpu/
https://stackoverflow.com/questions/27151903
复制相似问题