CSS :visited 选择器
选择访问过得链接样式:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
a:visited {
background-color: yellow;
}
</style>
</head>
<body>
<a href="https://www.mifengjc.com/">mifengjc.com</a>
<a href="http://www.google.com">Google</a>
<a href="http://www.wikipedia.org">Wikipedia</a>
<p><b>注意:</b> :visited选择器样式链接到你已经访问过的页面。</p>
</body>
</html>
定义和用法
:visited向访问过的链接添加特殊的样式。
Tip: 使用:visited选择器设置访问过的页面链接的样式, :hover选择器当有鼠标悬停在其上的链接样式,:active 选择器设置当你点击链接时的样式。
浏览器支持
表格中的数字表示支持该属性的第一个浏览器版本号。
| 选择器 | |||||
|---|---|---|---|---|---|
| :visited | 4.0 | 7.0 | 2.0 | 3.1 | 9.6 |
相关文章
CSS 教程: CSS 链接
CSS 教程: CSS 伪类
更多实例
激活的、已访问的、未访问的或者当有鼠标悬停在其上的链接:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
a:link {
color: green;
}
a:visited {
color: green;
}
a:hover {
color: red;
}
a:active {
color: yellow;
}
</style>
</head>
<body>
<p>将鼠标移上并点击此链接: <a href="https://www.mifengjc.com/">mifengjc.com</a></p>
</body>
</html>
不同样式的链接样式:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
a.ex1:hover,
a.ex1:active {
color: red;
}
a.ex2:hover,
a.ex2:active {
font-size: 150%;
}
a.ex3:hover,
a.ex3:active {
background: red;
}
a.ex4:hover,
a.ex4:active {
font-family: monospace;
}
a.ex5:visited,
a.ex5:link {
text-decoration: none;
}
a.ex5:hover,
a.ex5:active {
text-decoration: underline;
}
</style>
</head>
<body>
<p>将鼠标移至链接上查看其样式改变.</p>
<p><a class="ex1" href="/css/">这个链接改变颜色</a></p>
<p><a class="ex2" href="/css/">这个链接改变字体大小</a></p>
<p><a class="ex3" href="/css/">这个链接改变背景颜色</a></p>
<p><a class="ex4" href="/css/">这个链接改变字体类型</a></p>
<p><a class="ex5" href="/css/">这个链接改变文字修饰</a></p>
</body>
</html>
完整CSS选择器参考手册