与锚点和div悬停状态匹配的选择器与超链接不匹配

时间:2019-02-23 23:58:07

标签: html css

我的页面标记的格式如下:

<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>

是否存在另一个选择器来匹配此超链接标记?

1 个答案:

答案 0 :(得分:2)

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>