伪类选择器用于,某些选择器添加特殊的效果,比如给链接特殊效果,或者选择第一个,第N个元素
伪类选择器书写最大的特点是用冒号(:),比如 :hover
伪类选择器有很多,比如有链接伪类选择器,结构伪类选择器等
a:link 选择未被访问的链接
a:visited 选择所有已被访问链接
a:hover 选择鼠标指针位位于其上的链接
a:active 选择活动链接,鼠标指针按键未弹起的链接
html+css伪类选择器,为a标签链接添加效果
代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>伪类选择器-上</title>
<style>
a:link {
color: fuchsia;
text-decoration: none;
}
a:visited {
color: red;
}
a:hover {
color: chartreuse;
}
a:active {
color: deepskyblue;
font-weight: bold;
}
</style>
</head>
<body>
<a href="http://www.163.com/">网易</a>
<a href="http://www.taobao.com/">淘宝</a>
</body>
</html>
代码执行效果:
网易红色,为已点击过的链接;
淘宝蓝色,为鼠标按下未弹起的效果