【发布时间】:2017-09-12 12:35:52
【问题描述】:
https://codepen.io/anon/pen/veBQYy?editors=1100
我有一个带有类过滤器的 div。那个div是为了让背景图片更亮。我正在尝试使带有类内部的 div 位于过滤器之上。所以我把 z index: 9999 放在内部 div 上,但它没有到顶部
html, body {
height: 100%;
}
.outer {
display: table;
height: 100%;
width: 100%;
background: url('https://static.pexels.com/photos/56875/tree-dawn-nature-bucovina-56875.jpeg');
background-size: cover;
}
.middle {
display: table-cell;
width: 100%;
vertical-align: middle;
text-align: center; // Center everything in div
}
/* To dim background */
.filter {
position: absolute;
width: 100%;
height: 100%;
top: 0;
background-color: black;
opacity: 0.5;
}
/* This is not working. Z index not bringing it to the top */
.inner {
z-index: 9999;
}
h1 {
color: white;
}
<section class="outer">
<div class="middle">
<div class="filter"></div>
<div class="inner">
<h1>Need</h1>
<h1>This to go on top zindex 9999 not working</h1>
</div>
</div>
</section>
【问题讨论】: