CSS Z-index不起作用(绝对位置) [英] CSS z-index not working (position absolute)
本文介绍了CSS Z-index不起作用(绝对位置)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将黑色的 div
(相对)设置在第二个黄色的(绝对值)上方。黑色的 div
的父级也具有绝对位置。
I am trying to make the black div
(relative) above the second yellow one (absolute). The black div
's parent has a position absolute, too.
#relative {
position: relative;
width: 40px;
height: 100px;
background: #000;
z-index: 1;
margin-top: 30px;
}
.absolute {
position: absolute;
top: 0; left: 0;
width: 200px;
height: 50px;
background: yellow;
z-index: 0;
}
<div class="absolute">
<div id="relative"></div>
</div>
<div class="absolute" style="top: 54px"></div>
预期结果:
推荐答案
删除
z-index:0;
来自 .absolute
。
这篇关于CSS Z-index不起作用(绝对位置)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文