[英]how to change the default color of a link in html? (a:link)
我想在以下腳本中將超鏈接的默認藍色更改為綠色,但我一直收到粉紅色鏈接。
如果沒有點擊鏈接,你能告訴我如何將它變成綠色嗎? 提前致謝。
我要找的是這個:
<!DOCTYPE html> <html> <head> <style> a:link { color: green; background-color: transparent; text-decoration: none; } a:visited { color: pink; background-color: transparent; text-decoration: none; } a:hover { color: red; background-color: transparent; text-decoration: underline; } a:active { color: yellow; background-color: transparent; text-decoration: underline; } </style> </head> <body> <p>You can change the default colors of links</p> <a href="http://www.w3schools.com/html/html_images.asp" target="_blank">HTML Images</a> </body> </html>
問題是
a:visited {
color: pink;
background-color: transparent;
text-decoration: none;
}
訪問過的鏈接將顯示為粉紅色,因此如果您希望訪問過的鏈接和正常鏈接為綠色,請使用
a:link {
color: green;
background-color: transparent;
text-decoration: none;
}
a:visited {
color: green;
background-color: transparent;
text-decoration: none;
}
問題出在 ":link" 上,只需將其刪除即可。
這不合邏輯。 如果您為訪問過的鏈接定義顏色(粉紅色),那么所有訪問過的鏈接都會變成粉紅色!
我猜您正在嘗試做一個導航欄並顯示活動頁面,對嗎?
所以檢查這個例子:
http://www.w3schools.com/css/tryit.asp?filename=trycss_navbar_horizontal_black_active
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.