我该怎么办改变链接颜色?

时间:2016-02-07 00:27:34

标签: css

我只是想改变链接颜色。最初它会显示红色,如果它被访问然后绿色和鼠标悬停黄色。但它从第一个开始显示绿色。我在哪里做错了?

<html>
<head>
<style type="text/css">
a.class1:link  { color: red;}
a.class1:visited { color: green;}
a.class1:hover { color: yellow;}
</style>
</head>
<body>
Down there is a link...
<br>
<span class="class1">
<a href="http://www.google.com" target="_blank" class="class1">Google</a>
</span>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

因为您定位的是spana加上您已经访问了http://www.google.com,所以请按以下方式进行:

&#13;
&#13;
a.class1:link {
  color: red;
}
a.class1:visited {
  color: green;
}
a.class1:hover {
  color: yellow;
}
&#13;
This link will be red (because you -OP- didn't visit yet)
<span>
<a href="#randomlinkhere" target="_blank" class="class1">Google</a>
</span>

<hr />
This link will be green (because you -OP- already visited)
<span>
<a href="http://www.google.com" target="_blank" class="class1">Google</a>
</span>
&#13;
&#13;
&#13;

相关问题