gpt4 book ai didi

html - css伪元素不会显示

转载 作者:行者123 更新时间:2023-11-28 17:25:47 24 4
gpt4 key购买 nike

我正在制作一个导航菜单(遵循教程),并且为了制作导航图标我显然必须使用伪元素。正常情况下会很好,但这一次,他们根本不会出现......

我的代码有问题吗/有没有更好的方法来制作图标?

*,
*::before,
*::after {
box-sizing: inherit;
padding: 0;
margin: 0;
}
body {
padding: 0;
margin: 0;
background-color: #FFF
-webkit-font-smoothing: antialiased;
}
a {
color: hsla(37, 39%, 72%, 1.00);
text-decoration: none;
}
li{
list-style: none;
}
.header {
width: 100vw;
height: 100vh;
display: block;
background:url(img/background.jpg) no-repeat center center;
background-size: cover;
position: relative;
}
.logo {
font-size: 4em;
color: #FFF;
line-height: 1.1;
border: 1px solid #fff;
border-radius: 100%;
width: 80px;
height: 80px;
display: inline-block;
padding: 5px;
background-color: hsla(152, 40%, 20%, 1.00);
margin: 50px 0 0 50px;
cursor: pointer;
}
.nav-icon {
width: 50px;
height: 40px;
display: block;
background-color: transparent;
position: absolute;
top: 70px;
right: 50px;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-o-user-select: none;
user-select: none;
}
.nav-icon .icon {
width: 50px;
height: 2px;
display: block;
background-color: #333;
position: absolute;
top: 20px;
}

.nav-icon .icon::before
.nav-icon .icon::after {
content: "";
width: 50px;
height: 2px;
display: block;
background-color: #FFF
position: absolute;
height: 100%;
}

.nav-icon .icon::before {
top: -10px;
}
.nav-icon .icon::after {
top: 10px;
}

最佳答案

您在某些行中遗漏了分号 ; 和在

中遗漏了逗号 ,
.nav-icon .icon::before ,
.nav-icon .icon::after {
content: "";
width: 50px;
height: 2px;
display: block;
background-color: #FFF
position: absolute;
height: 100%;
}

这解决了你正在寻找的问题

关于html - css伪元素不会显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40153068/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com