css伪元素不会显示

时间:2016-10-20 11:23:48

标签: html css navigation pseudo-element

我正在制作导航菜单(遵循教程),并且要制作导航图标,我显然必须使用伪元素。通常这样会很好,但这一次,它们根本就不显示......

我的代码是否有问题?是否有更好的方法来制作图标?

*,
*::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;
}

1 个答案:

答案 0 :(得分:1)

您错过了某些行中的分号;

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

修复了你想要的东西