gpt4 book ai didi

html - 悬停和焦点不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 10:28:48 24 4
gpt4 key购买 nike

我目前正在尝试让悬停效果起作用,但是我似乎无法在检查元素中找到悬停和焦点状态,所以我认为他们现在没有出现我出错的地方?同样值得注意的是我正在运行 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>

最佳答案

改变

.nav-wrapper a::before:hover, .nav-wrapper a::before:focus

.nav-wrapper a:hover::before, .nav-wrapper a:focus::before

:hover:focus 选择器是伪类,因此应该优先于 ::before 等伪元素和 ::after

关于html - 悬停和焦点不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36647697/

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