我知道那里有关于伪元素的图片'自己的关系。
(来自CSS tricks)
我遇到了一个问题,我想在.nav-box
的黑色面前制作.nav-box::after
的白色背景色,如同浮动菜单列表。虽然我看过this from previous question,但似乎无法完成上述工作。想检查一下。
代码也在JSBIN上。
body {
position: relative;
z-index: 1;
}
.nav-box {
position: relative;
z-index: 50; /* no effects */
top: 0;
right: 0;
width: 60vw;
height: 100vh;
border: 1px solid red;
background-color: white;
}
.nav-box::after {
position: absolute;
z-index: -1;
content:"";
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: black;
}
.nav-box::before {
/* this will be a menu button */
position: absolute;
z-index: 10;
right: 0;
content: "O";
color: orange;
font-size: 40px;
}

<body>
<nav class="nav-box">
<ul class="menu-box">
<li><a href="">About</a></li>
<li><a href="">Blog</a></li>
<li><a href="">Contact</a></li>
</ul>
</nav>
</body>
&#13;
答案 0 :(得分:1)
我不完全确定你想要实现的目标,但尝试一下 从.nav-box中删除z-index。