gpt4 book ai didi

css - 如何在不工作之前将鼠标悬停在另一个用途上时更改一个元素

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

HTML

<div class="related_files_data">
<h2>
<a href="./?a=content.id&amp;id=96">example 1</a>
</h2>
<h2>
<a href="./?a=content.id&amp;id=95">example 2</a>
</h2>

CSS

.related_files_data h2::before {
color: #6dd7f8;
content: "";
font-family: fontawesome;
font-size: 14px;
}
.related_files_data:hover + h2::before {
color: #f8482e;
content: "";
font-family: fontawesome;
font-size: 14px;
}

我想更改悬停第一个元素上的图标

使用写得不好的代码

最佳答案

使用selector:state:psuedo,您可以将选择器定位到它的状态:

.related_files_data h2:hover:before{
color: #f8482e;
content: "";
font-family: fontawesome;
font-size: 14px;
}

.related_files_data h2::before {
color: #6dd7f8;
content: "";
font-family: fontawesome;
font-size: 14px;
}
.related_files_data h2:hover::before {
color: #f8482e;
content: "";
font-family: fontawesome;
font-size: 14px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"/>
<div class="related_files_data">
<h2>
<a href="./?a=content.id&amp;id=96">example 1</a>
</h2>
<h2>
<a href="./?a=content.id&amp;id=95">example 2</a>
</h2>

关于css - 如何在不工作之前将鼠标悬停在另一个用途上时更改一个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46138884/

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