HTML中超链接的悬停颜色

3
我希望当鼠标悬停在超链接上时,它的颜色会改变。但目前来看,它仍然是黑色的,很难看出这个文本是一个超链接。
以下是HTML代码:
&lth4 style="text-align: left;">&lta href="hyperlink" target="_blank">&ltspan style="color: #000000;">制作 #bobthebrewbus 的过程</span></a></h4>
3个回答

5

    a:hover {color: red;}
    a { color: black; text-decoration: none;}
<h4 style="text-align: left;"><a href="hyperlink" target="_blank">The making of #bobthebrewbus</a></h4>


0

<style type="text/css">
<!--
a:link {color: #000000; text-decoration: underline; }
a:active {color: #0000ff; text-decoration: underline; }
a:visited {color: #008000; text-decoration: underline; }
a:hover {color: #ff0000; text-decoration: none; }
-->
</style> 


0
您可以添加以下CSS:
h4 a:hover span {
    color: red !important; // Change the color to your preference.
}

:hover 用于指定当鼠标悬停在锚点上时会发生什么。我添加了 !important,这样它就可以覆盖 span 元素中的内联 CSS。如果将内联 CSS 移动到外部 CSS 中,则可能不需要 !important 声明。


我正在处理一个WordPress网站,并翻转到文本编辑模式,以便只使用HTML。我能否改为CSS或如何将其翻译成HTML并添加到代码中? - Tim Forssman
你需要在文档中的样式标签中编写CSS。伪类(如:hover)不是指向一个元素,而是指向满足样式表规则条件的任何元素。 - ankitjain11

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接