2017-02-13 432 views
-1

我想在下面的脚本中将超链接的默认蓝色更改为绿色,但我不断收到粉红色链接。如何在html中更改链接的默认颜色? (a:链接)

你能让我知道如何在链接没有被点击时将它变成绿色?提前致谢。


我所寻找的是这样的:

  • a)拥有,当它没有被点击尚未
  • B A绿色链接)有一个红色的链接,当鼠标悬停在链接
  • C)有一个黄色链接,当鼠标点击该链接
  • d)当有后的链接被点击一个粉红色的链接

<!DOCTYPE html> 
 
    <html> 
 
    <head> 
 
<style> 
 

 
a:link { 
 
    color: green; 
 
    background-color: transparent; 
 
    text-decoration: none; 
 
} 
 
a:visited { 
 
    color: pink; 
 
    background-color: transparent; 
 
    text-decoration: none; 
 
} 
 
a:hover { 
 
    color: red; 
 
    background-color: transparent; 
 
    text-decoration: underline; 
 
} 
 
a:active { 
 
    color: yellow; 
 
    background-color: transparent; 
 
    text-decoration: underline; 
 
} 
 
</style> 
 
</head> 
 
<body> 
 

 
<p>You can change the default colors of links</p> 
 

 
<a href="http://www.w3schools.com/html/html_images.asp" 
 

 
target="_blank">HTML Images</a> 
 

 
</body> 
 
</html>

+0

如果您是从网上复制的学校代码,只需使用他们提供的演示:http://www.w3schools.com/css/css_link.asp – wlh

+0

的问题是演示本身带有错误♣♦ – T100

+0

我认为你的代码可能很好。它为我工作。但是你需要明白,当你点击链接时链接不会变成粉红色,如果有人已经访问了页面,那么它会变成粉红色。所以如果你去过这个页面,它会变成粉红色的。 – StephenCollins

回答

0

问题是

a:visited { 
    color: pink; 
    background-color: transparent; 
    text-decoration: none; 
} 

访问过的链接会被涂上粉红色,所以如果你想参观和正常链接是绿色的,然后使用

a:link { 
    color: green; 
    background-color: transparent; 
    text-decoration: none; 
} 
a:visited { 
    color: green; 
    background-color: transparent; 
    text-decoration: none; 
} 
+0

我想要正常的链接是绿色的,访问过的链接是粉红色的。 ☺ – T100

0

问题出在“:link “只是删除它。

+0

我删除它,仍然得到粉红色的链接 – T100