我有这样的代码:努力落实HREF CSS中div标签
<div id="NAHC-topText">
<h2><a href="index.html">Link To Somewhere</a></h2>
</div>
我想有CSS删除下划线并改变悬停颜色上链接的用户滚动。该链接加载简单的HTML。 我没有看到能够成功地在div标签中实现此功能。
任何线索?
谢谢
我有这样的代码:努力落实HREF CSS中div标签
<div id="NAHC-topText">
<h2><a href="index.html">Link To Somewhere</a></h2>
</div>
我想有CSS删除下划线并改变悬停颜色上链接的用户滚动。该链接加载简单的HTML。 我没有看到能够成功地在div标签中实现此功能。
任何线索?
谢谢
所以只需在CSS中设置适当的值。
a {
text-decoration: none;
}
a:hover {
color: red;
}
根据您的实际需要,你可能想选择更改为#NAHC-topText a
而不是仅仅a
。
在adittion到Sirko的答案,如果你想只影响
<a>
内此致
<div id="NAHC-topText"> <h2>
您的样式应该是这样的,以排除任何其他锚和头部。
#NAHC-topText h2 a {text-decoration:none;}
#NAHC-topText h2 a:hover {color:red;}
但是Sirko的答案当然没有错,只是它会影响特定文档中的所有锚点。
另外如果你想下划线只显示在悬停,您只需定义
a {text-decoration:none;}
a:hover {text-decoration:underline;color:red;}
与您所选择
的特定选择,现在我又红你的问题,这适用于反之亦然相反的情况 当你想要它第一个下划线时,并没有下划线悬停,你只需交换条件为每种情况。
<style>
#NAHC-topText a{text-decoration:none;}
#NAHC-topText a:hover{color:red;}
</style>
#NAHC-topText a:hover{
color: red;
text-decoration:none;
}
我认为他想强调,直到它的上空盘旋。 – George