我目前正试图让悬停效果起作用但是我似乎无法在inspect元素中找到悬停和焦点状态所以我认为他们现在没有出现在我出错的地方?另外值得注意的是我正在运行autoprefixer。
CSS
.nav-wrapper {
display: flex;
padding: 12px 10px 10px;
flex-flow: column;
}
.nav-wrapper a {
margin-top: 30px;
font-size: 18px;
color: rgba(0, 0, 0, 0.2);
font-weight: 700;
position: relative;
display: inline-block;
outline: none;
text-decoration: none;
text-transform: uppercase;
letter-spacing: 1px;
text-shadow: 0 0 1px rgba(255, 255, 255, 0.3);
}
.nav-wrapper a::before {
color: green;
content: attr(data-hover);
position: absolute;
transition: transform 0.7s, opacity 0.7s;
}
.nav-wrapper a::before:hover, .nav-wrapper a::before:focus {
transform: scale(0.9);
opacity: 0;
}
HTML
<nav class="nav-wrapper">
<a class="nav-child" data-hover="About Me" href="#">About Me</a>
<a class="nav-child" data-hover="Work" href="#">Work</a>
<a class="nav-child" data-hover="Process" href="#">Process</a >
<a class="nav-child" data-hover="Contact Me" href="#">Contact Me</a>
</nav>
答案 0 :(得分:1)
更改
.nav-wrapper a::before:hover, .nav-wrapper a::before:focus
到
.nav-wrapper a:hover::before, .nav-wrapper a:focus::before
:hover
和:focus
选择器是伪类,因此应优先于::before
和::after
等伪元素。
答案 1 :(得分:0)
:: before和:focus /:hover必须切换。
哦,我看到别人在我面前xD