gpt4 book ai didi

html - 悬停在元素上时更改文本和链接的颜色

转载 作者:太空宇宙 更新时间:2023-11-04 14:59:58 25 4
gpt4 key购买 nike

我有一个非常简单的元素,其中包含一些文本或链接。

当我将鼠标悬停在元素上时,我想同时更改文本颜色和链接颜色。我无法让它工作,我认为这是因为你不能选择 2 个伪类。我怎样才能让这样的东西发挥作用?

CSS:

.test, .test a:link, .test a:visited {
color: white;
text-decoration: none;
}

.test:hover, .test:hover .test a:link, .test:hover .test a:visited {
color: yellow;
text-decoration: none;
}

html:

<div class="test">
testtext<br>
<a href="#">testlink</a>
</div>

最佳答案

只需正确链接到您的路径:

.test,
.test a:link,
.test a:visited {
color: white;
text-decoration: none;
}
.test:hover,
.test:hover a:link,
.test:hover a:visited {
color: yellow;
text-decoration: none;
}

jsfiddle

关于html - 悬停在元素上时更改文本和链接的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35525188/

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