单击链接时不要更改链接颜色 [英] Don't change link color when a link is clicked

查看:164
本文介绍了单击链接时不要更改链接颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在HTML页面中有一个链接:

I have a link in an HTML page:

<a href="#foo">foo</a>

链接文本的颜色最初是蓝色的。单击链接时,链接文本的颜色首先变为红色,然后变为蓝色。我想要的颜色的链接文字不改变时,用户点击它。

The color of the link text is originally blue. When the link is clicked, the color of the link text changes to Red first, and then changes back to Blue. I want to the color of the link text not to change when user clicks on it. How can I make it happen?

我尝试了

a:active {
    color: none;
}

,但没有运气。

而我不想在CSS中使用:

And I don't want to use this in CSS:

a:active {
    color: blue;
}

,因为链接文本的原始颜色可以是蓝色之外的一些。

, because the original color of the link text can be some other than blue.

感谢。

编辑:该页面显示在iPhone浏览器上,

the page is displayed on iPhone browser, and I want to make a:active to keep the original link text color.

推荐答案

您正在寻找这个:

a:visited{
  color:blue;
}

链接有几个状态你可以改变...我记得他们的方式LVHFA(Lord Vader's Handle Formerly Anakin)

Links have several states you can alter... the way I remember them is LVHFA (Lord Vader's Handle Formerly Anakin)

每个字母代表一个伪类:(Link,Visited,Hover,Focus,Active)

Each letter stands for a pseudo class: (Link,Visited,Hover,Focus,Active)

a:link{
  color:blue;
}
a:visited{
  color:purple;
}
a:hover{
  color:orange;
}
a:focus{
  color:green;
}
a:active{
  color:red;
}

如果您希望链接始终为蓝色,蓝色。我会注意到,虽然在可用性级别,这将是很好,如果鼠标点击导致颜色更改一点(即使只是一个更浅/更深的蓝色),以帮助指示链接实际上点击(这是特别重要的

If you want the links to always be blue, just change all of them to blue. I would note though on a usability level, it would be nice if the mouse click caused the color to change a little bit (even if just a lighter/darker blue) to help indicate that the link was actually clicked (this is especially important in a touchscreen interface where you're not always sure the click was actually registered)

如果您有不同类型的链接,点击时所有的颜色都相同,为链接添加一个类。

If you have different types of links that you want to all have the same color when clicked, add a class to the links.

a.foo, a.foo:link, a.foo:visited, a.foo:hover, a.foo:focus, a.foo:active{
  color:green;
}
a.bar, a.bar:link, a.bar:visited, a.bar:hover, a.bar:focus, a.bar:active{
  color:orange;
}

应该注意,并非所有浏览器都遵循这些选项;-)

It should be noted that not all browsers respect each of these options ;-)

这篇关于单击链接时不要更改链接颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆