Html 访问后如何使链接不变色?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8188060/
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
How to make link not change color after visited?
提问by GeekedOut
I have this css:
我有这个 css:
a:visited
{
text-decoration: none;
decoration: none;
}
After a link is visited it changes color.
访问链接后,它会改变颜色。
It is happening to the "Browse All Problems" link on the bottom of the right side of this page: http://www.problemio.com
此页面右侧底部的“浏览所有问题”链接正在发生这种情况:http: //www.problemio.com
Thanks!
谢谢!
回答by Matt Stauffer
Text decoration affects the underline, not the color.
文本装饰影响下划线,而不是颜色。
To set the visited color to the same as the default, try:
要将访问的颜色设置为与默认颜色相同,请尝试:
a {
color: blue;
}
Or
或者
a {
text-decoration: none;
}
a:link, a:visited {
color: blue;
}
a:hover {
color: red;
}
回答by eversor
In order to avoid duplicate code, I recommend you to define the color once, for both states:
为了避免重复代码,我建议您为两种状态定义一次颜色:
a, a:visited{
color: /* some color */;
}
This, indeeed, will mantain your <a>
color (whatever this color is) even when the link has been visited.
这确实会保持您的<a>
颜色(无论这种颜色是什么),即使链接已被访问。
Notice that,if the color of the element inside of the <a>
is being inherited (e.g. the color is set in the body
), you could do the following trick:
请注意,如果 内部元素的颜色<a>
被继承(例如颜色设置在 中body
),您可以执行以下技巧:
a, a:visited {
color: inherit;
}
回答by Royi Namir
Simply give it a css color
简单地给它一个css颜色
like :
喜欢 :
a
{
color:red;
}
回答by BlackHat
For application on all the anchor tags, use
对于所有锚标签的应用,使用
CSS
CSS
a:visited{
color:blue;
}
For application on only some of the anchor tags, use
对于仅在某些锚标记上的应用,请使用
CSS
CSS
.linkcolor a:visited{
color:blue;
}
HTML
HTML
<span class="linkcolor"><a href="http://stackoverflow.com/" target="_blank">Go to Home</a></span>
回答by any
you can use a diferent class:
您可以使用不同的类:
like
喜欢
.clase
{
text-decoration-color: none;
color: #682864;
text-decoration: none;
}
.clase2:hover
{
color: white;
text-decoration: none;
}
<a href="#" class="clase2 clase"> link que no tiene subrayado ni color standar</a>
回答by wiztrail
If you want to set to a new color or prevent the change of the color of a specific link aftervisiting it, add inside the tag of that link:
如果要设置为新颜色或在访问特定链接后阻止更改颜色,请在该链接的标签内添加:
<a style="text-decoration:none; color:#ff0000;" href="link.html">test link</a>
Above the color is #ff0000 but you can make it anything you'd like.
颜色上方是#ff0000,但您可以随意设置。
回答by James Johnson
Something like this should work:
这样的事情应该工作:
a, a:visited {
color:red; text-decoration:none;
}
回答by MiDo
a:visited
{
color: #881033;
}
(or whatever color you want it to be)
(或任何你想要的颜色)
text-decoration
is for underlining(overlining etc.
decoration
ist not a valid css rule.
text-decoration
用于下划线(上划线等)
decoration
不是有效的 css 规则。
回答by TryThis
(Header CSS:)
<style>
a {
color: #ccc; /* original colour state*/
}
a:active {
color: #F66;
}
a[tabindex]:focus {
color: #F66;
outline: none;
}
</style>
(Body HTML:)
<a href="javascript:;" style="font-size:36px; text-decoration:none;" tabindex="1">click me ♥</a>