如何解决在CSS中使用:after悬停
我的HTML如下所示
<li class="category">Hair</li>
我的CSS代码如下所示
.category:hover:after {
position: absolute;
content: "\f054" !important;
font-family: "Font Awesome 5 Free";
font-weight: 900;
right: 18px;
top: 15px;
font-size: 18px;
color: #ff0052;
}
当我将鼠标悬停在Hair
上时,颜色没有更改为#ff0052
。
解决方法
.category {
position: relative;
cursor: pointer;
}
.category:hover{
color: red !important;
}
.category:hover::after {
content: "++";
position: absolute;
font-weight: 900;
top: 15px;
font-size: 18px;
color: red !important;
}
<li class="category">Hair</li>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。