html - 匹配锚点和 div 悬停状态的选择器与超链接不匹配
问题描述
我的页面标记形成如下:
<a href="#Products">
<div id="Tag">
<span>A website hyperlink</span>
</div>
</a>
#Tag {
opacity: 1;
filter: drop-shadow(0px 3px 6px rgba(0, 0, 0, 0.161));
position: absolute;
left: 50px;
top: 107px;
box-sizing: border-box;
margin: 0;
padding: 0;
overflow: visible;
width: 527px;
white-space: nowrap;
text-align: left;
font-family: Arial;
font-style: normal;
font-weight: bold;
font-size: 55px;
color: rgba(255,255,255,1);
}
如您所见,颜色是在容器上明确设置的。
我想改变悬停时的颜色。
a:hover {
color: red !important;
}
a:hover {
color: red !important;
}
#Tag {
opacity: 1;
position: absolute;
left: 20px;
top: 20px;
box-sizing: border-box;
margin: 0;
padding: 0;
overflow: visible;
width: 527px;
white-space: nowrap;
text-align: left;
font-family: Arial;
font-style: normal;
font-weight: bold;
font-size: 35px;
color: rgba(0,0,0,1);
}
<a href="#Products">
<div id="Tag">
<span>A hyperlink</span>
</div>
</a>
是否有另一个选择器来匹配这个超链接标记?
解决方案
a:hover * {
color: red !important;
}
#Tag {
opacity: 1;
position: absolute;
left: 20px;
top: 20px;
box-sizing: border-box;
margin: 0;
padding: 0;
overflow: visible;
width: 527px;
white-space: nowrap;
text-align: left;
font-family: Arial;
font-style: normal;
font-weight: bold;
font-size: 35px;
color: rgba(0,0,0,1);
}
<a href="#Products">
<div id="Tag">
<span>A hyperlink</span>
</div>
</a>
推荐阅读
- python - 如何在python中将单个pdf的多页转换为一个TIFF文件
- react-native - 用玩笑测试应用程序时无法读取未定义的属性“默认”
- python - 通过预先应用的参数移动多个文件
- php - 如果 url 是根域添加类 (PHP)
- android - BLE 扫描功能在 ionic v4 应用程序中无法正常工作
- php - 如何将数据存储到存在行
- ios - 将 Firebase 添加到 Pod 项目
- python - 如何使用 Py_LIMITED_API 使用 Python3 C API 定义子类?
- rust - 我无法从函数中获得值的所有权
- java - 使用多种方法格式化问题并使变量相关