CSS 如何在不选择颜色的情况下禁用自动链接着色?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2204634/
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 21:31:41  来源:igfitidea点击:

How to disable automatic links coloring without selecting a color?

css

提问by Ryan

this is really confusing, i don't want the browser to change the color of links, so the links color will stay same as specified in <font>. i know that i can specify a color with the property A:link, but that's not what i want.

这真的很令人困惑,我不希望浏览器更改链接的颜色,因此链接颜色将与<font>. 我知道我可以用属性指定颜色A:link,但这不是我想要的。

Thanks

谢谢

回答by simaofreitas

If you don't want any coloration just do something like this:

如果您不想要任何着色,请执行以下操作:

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

If it still hovers, just do "a, a:hover, a:visited, a:active {...}

如果它仍然悬停,只需执行 "a, a:hover, a:visited, a:active {...}

回答by Vance C.

If anyone cares this is what I did with buttons that I made from the links. Probably have to watch out for the inheritance but it worked perfect in my case. Good luck!

如果有人关心,这就是我使用链接制作的按钮所做的。可能必须注意继承,但在我的情况下它工作得很好。祝你好运!

HTML:

HTML:

<a class="button blue" href="/">Place Your Order Today</a>

CSS:

CSS:

a.button:visited
{
 color:inherit;
}
.button
{
 padding: 6px 8px;
 font-size: 14px;
 font-weight: bold;
 text-decoration: none;
 margin-right: 10px;
 border-radius: 6px;
}
.blue
{
 border: 1px solid #2d748c;
 background-color: #40b5dc;
}

回答by ЯegDwight

Specify the same color for a:visitedand maybe also a:hoverand a:activeor simply put the color inline like this:

a:visitedand指定相同的颜色,也可能a:hovera:active或简单地将颜色内联,如下所示:

<a href="url" style="color:#69c">link text</a>

<font>is deprecated anyway.

<font>无论如何都被弃用了。

回答by jpsimons

I'm pretty sure there's no way to do what you're describing. But if you want the link color to match the body text color, I'd recommend this...

我很确定没有办法做你所描述的。但是,如果您希望链接颜色与正文颜色相匹配,我建议您这样做...

The body text color came from somewhere. Probably a CSS definition. Inspect some text in Firebug to see exactly where the applied color was defined. For example, maybe it points you to a rule like this:

正文颜色来自某个地方。可能是 CSS 定义。检查 Firebug 中的一些文本以准确查看应用颜色的定义位置。例如,它可能会指向这样的规则:

body { color:#666; }

Just add in your A tag right there, so it would be like this. I know it's redundant but I really don't think CSS has a way to say "inherit from one level higher in the cascade than you usually would."

只需在那里添加您的 A 标签,它就会是这样的。我知道这是多余的,但我真的不认为 CSS 有办法说“从级联中比通常更高的一层继承”。

body, a { color:#666; }