老师解答。
来源:3-2 表示层--导航的实现
很多本正经的男人
2019-06-12 13:44:22
用after伪元素这样写可以吗?还是没听懂老师说的用before伪元素来设置的背景线是如何在景区按钮下面的。
*{
padding: 0;
margin: 0;
border: none;
}
html,
body{
height: 100%;
background: #93b3c6;
}
span {
display:block;
width: 16px;
height: 16px;
margin: 30px auto 40px;
border-radius: 50%;
background: #fff;
}
nav {
position: relative;
display: flex;
width: 78.125vw;
margin: 0 auto 45px;
justify-content: space-between;
}
nav:after/*before*/ {
position: absolute;
top: 12px;
width: 100%;
height: 10px;
background: #fff;
display: block;
content: '';
}
nav > a {
/*position: relative;*/
font-size:12px; padding: 10px; border: 2px solid #5935b4;
color: #255d7e;
text-decoration: none;
background: #fff;
z-index: 1;
}
1回答
你好,这样写也可以。
用伪类before或者after在这里都是一样的,都需要定位控制元素显示的位置,都是可以的。
祝学习愉快!
相似问题