Html 如何在悬停时停止更改颜色的链接?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23907694/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:54:12  来源:igfitidea点击:

How do I stop a link changing color on hover?

htmlcss

提问by Joe Fenny

I have an email link on my page that goes blue when hovered over.

我的页面上有一个电子邮件链接,当鼠标悬停在上面时会变成蓝色。

I can't seem to fix this, i don't want it to change at all. In it's CSS i have it as:

我似乎无法解决这个问题,我根本不想改变它。在它的 CSS 中,我将其定义为:

.emaillink2
{   text-decoration: none;
color: white;}

a.hover:hover
{   text-decoration: none;
color: white;}

#headerinfo
{
float: right;
font-size: 32px;
color: white;
z-index: 1;
text-align: right;
margin-top: 20px;
text-decoration: none;
}

The div's HTML:

div 的 HTML:

<div id="headerinfo">
Telephone: 07777777777
<br/>
Fax: 07777777777
<br/>
Email: <a href="mailto:[email protected]" class="emaillink2">[email protected]</a>
</div>

However it still changes color when hovered over.

然而,当悬停在上面时它仍然会改变颜色。

回答by Janaka R Rajapaksha

Change this code:

更改此代码:

.emaillink2
{   text-decoration: none;
color: white;}

to this code:

到这个代码:

.emaillink2, .emaillink2:hover
{   text-decoration: none;
color: white;}

回答by Suresh Ponnukalai

Instead this

而是这个

a.hover:hover
{   
  text-decoration: none;
  color: white;
}

Use like this.

像这样使用。

a:hover
{   
  text-decoration: none;
  color: white;
}