使用伪类,对链接样式化举例:
实际还可以设置一个 cursor
属性,值有 pointer
, wait
, help
等等
a:link
仅选择具有 href
属性的 a
,因此对 <a>something</a>
不起作用
a:active
选择链接被点击时的状态,即鼠标被点击,且还未释放,为 active
/* styling links */
a:link {
color: #1098ad;
/* get rid of underline */
text-decoration: none;
}
a:visited {
color:#1098ad
}
a:hover {
color:orangered;
font-weight: bold;
/* text-decoration: underline wavy orangered; */
text-decoration: underline orangered;
}
/* the state of clicking */
a:active {
background-color: black;
color:blue;
font-style:italic;
}