z-index不适用于其::before
/::after
元素。我在这里分享下面的代码。z-index在:: after/:: before元素之后不起作用?
.or {
border: 2px solid #8fc300;
border-radius: 5px;
color: #333;
font-size: 17px;
font-weight: 600;
height: 34px;
line-height: 26px;
text-align: center;
width: 34px;
margin-top: 64px;
margin-left: 20px;
margin-right: 20px;
background: #fff;
/*For z-index - keep the green area on top*/
position: relative;
z-index: 11;
}
.or::after {
background: red;
content: "";
display: block;
height: 116px;
margin-left: 15px;
margin-top: -68px;
width: 4px;
/*For z-index - keep the green area on top*/
position: relative;
z-index: 9;
}
<div class="or"></div>
这里在我的场景中,'.or'住在一个'modal'中,所以它必须有一个'z-index'值,否则如果我为'or :: after'设置'z-index:-1',它在模态之下。有没有解决方案保留'z-index'与父'.or'? –
你可以为你创建演示程序吗?如果没有它,很难告诉解决方案。 –
请看这里。 http://jimfahad.com/onewave/3/game-play.html(点击“创建帐户”按钮 - http://prntscr.com/chyqap) –