我正在尝试从 <a>
中删除所有链接样式标签。我尝试了各种各样的事情,但没有任何效果。我可以让下划线消失,但访问过的链接仍然保持不同的颜色。简单的解决方法是预先设置文本的颜色(并且可行),但我不想那样。我在这里重现了这个问题:https://jsfiddle.net/qod4dz5x/
我假设这与我有一个 <h2>
有关<a>
内的标签标签?
<a href="http://google.com"><h2>
Google
</h2></a>
a:link {
text-decoration: none !important;
}
a:visited {
text-decoration: none !important;
}
a:hover {
text-decoration: none !important;
}
a:active {
text-decoration: none !important;
}
我错过了什么?感谢您提供任何有用的信息。
最佳答案
正如 Wowsk 上面提到的,文本修饰指的是下划线,而不是颜色。你需要一个单独的规则:
a:visited {
text-decoration: none;/*important is not necessary here or in any of the other psuedo selectors */
color:black;/* or any color*/
}
或者,您可以只为 <a>
设置颜色无论如何都会覆盖伪选择器的标签:
a {
color:black;
text-decoration:none;
}
关于javascript - 标签上的文字装饰不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35931115/