如何删除html超链接'a'标签的默认链接颜色?

问题描述 投票:199回答:10

默认链接颜色为蓝色。如何删除html超链接标签<a>的默认链接颜色?

html css anchor html-helper
10个回答
394
投票

inherit value

a { color: inherit; } 

...会使元素呈现其父元素的颜色(这是我认为你正在寻找的)。


48
投票

你可以做这样的事情:

a {
    color: #0060B6;
    text-decoration: none;
}

a:hover 
{
     color:#00A0C6; 
     text-decoration:none; 
     cursor:pointer;  
}

17
投票
.cancela,.cancela:link,.cancela:visited,.cancela:hover,.cancela:focus,.cancela:active{
    color: inherit;
    text-decoration: none;
}

我觉得有必要发布上面的类定义,SO的许多答案都会错过一些状态


10
投票

如果您不想看到浏览器提供的文本修饰和默认颜色,则可以将以下代码保留在main.css文件的顶部。因此,如果您需要一些不同的颜色和装饰样式属性,则可以在样式文件中的此代码段的下方轻松覆盖。

 a:hover, a:focus, a:active {
      text-decoration: none;
      color: inherit;
 }

7
投票

这也是可能的:

        a {
            all: unset;
        }

unset:此关键字指示将所有应用于元素或元素父级的属性更改为其父值(如果它们是可继承的)或更改为初始值(如果不可以)。 unicode-bidi和direction值不受影响。

资料来源:Mozilla description of all


7
投票

你必须使用CSS。这是一个更改默认链接颜色的示例,当链接只是坐在那里,何时被悬停以及它是一个活动链接时。

a:link {
  color: red;
}

a:hover {
  color: blue;
}

a:active {
  color: green;
}
<a href='http://google.com'>Google</a>

2
投票

只需在CSS中添加,

a {
    color: inherit;
    text-decoration: none;
}

就是这样,完成了。


2
投票

您可以使用CSS 2.0引入的System Color (18.2)值,但在CSS 3中已弃用。

a:link, a:hover, a:active { color: WindowText; }

这样,您的锚链接将与此系统上的普通文档文本具有相同的颜色。


0
投票
a:link{color:inherit;}

这是简单的一行可以为你做所有的东西<3

© www.soinside.com 2019 - 2024. All rights reserved.