[英]Links styling in CSS
為什么鏈接的以下樣式無效?
<html>
<head>
<style type="text/css">
a:link {color:#123456;} /* unvisited link */
</style>
</head>
<body>
<a href="http://www.google.com">Visit Google</a>
</body>
</html>
謝謝 !
對於某些一般的最佳實踐,鏈接樣式層次結構的工作方式如下:
a:link {
color: #ff0000;
}
a:visited {
color: #ff0000;
}
a:hover {
color: #cccccc;
}
a:focus {
color: #cccccc;
}
a:active {
color: #cccccc;
}
最好始終應用所有這些,無論您是按上面的方式單獨執行還是按以下方式進行操作:
a:link, a:visited {
color: #ff0000;
}
a:hover, a:focus, a:active {
color: #cccccc;
}
但是無論如何,順序非常重要,如果不遵循該順序,則可以覆蓋所有內容。
這是因為鏈接已被訪問。
嘗試
a {color: blue;} /* unvisited link */
a:visited {color: orange;} /* visited link*/
如果刪除最后一個聲明,則無論:visited
鏈接將變為藍色。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.