点击后如何更改超链接的颜色 [英] How to change the color of hyperlink after click it

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

问题描述

我想在点击它后改变超链接的颜色,但其余超链接的颜色也改变了。

CSS



  a:active {
color:grey;
}
a:visited {
color:black;



HTML



 <身体GT; 
< a href =link1.html> a< / a>
< a href =link2.html> b< / a>
< a href =link3.html> c< / a>
< / body>


解决方案

:visited 伪类在浏览器的历史记录上工作。所有三个链接都用黑色绘制的事实意味着您的浏览器在过去曾浏览过它们。如果您要清除历史记录,或更改链接的网址,则会发现它们未归类为已访问。



A 链接到StackOverflow 可能会显示为在您的浏览器中访问过,但链接到JIHAD的声音可能会显示出不同的颜色(除非你是塔利班的成员)。点击未访问的链接会将其颜色更改为访问颜色 - 如StackOverflow的样式表中所定义的那样 - 只要该页面存在于浏览器的历史记录中,就会保持已访问状态。


I want to change the color of the hyperlink after clicking on it, but remaining hyperlinks color are also changed..

CSS

a:active {
    color: gray;
}
a:visited {
    color:black;
}

HTML

<body> 
    <a href="link1.html">a</a>
    <a href="link2.html">b</a>
    <a href="link3.html">c</a> 
</body>

解决方案

The :visited pseudo-class works on the browser's history. The fact that all three links are being drawn with the black colour means that your browser has visited them in the past. If you were to clear your history, or change the links' urls, you'll find that they aren't classed as 'visited'.

A link to StackOverflow will probably show as visited in your browser, but a link to Voice of JIHAD probably shows up a different colour (unless you are a member of the Taliban). Clicking on the unvisited link will change its colour to the visited colour - as defined in StackOverflow's stylesheets - and will remain 'visited' as long as the page exists in your browser's history.

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

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