[英]how to change the default color of a link in html? (a:link)
I want to change the default blue color of hyperlinks to green in the following script but I keep getting a pink link.我想在以下脚本中将超链接的默认蓝色更改为绿色,但我一直收到粉红色链接。
Can you let me know how can I turn it to green when the link hasn't been clicked?如果没有点击链接,你能告诉我如何将它变成绿色吗? Thanks in advance.提前致谢。
What I am looking for is this:我要找的是这个:
<!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>
The problem is问题是
a:visited {
color: pink;
background-color: transparent;
text-decoration: none;
}
visited links will be colored pink, so if you want visited and normal links to be green then use访问过的链接将显示为粉红色,因此如果您希望访问过的链接和正常链接为绿色,请使用
a:link {
color: green;
background-color: transparent;
text-decoration: none;
}
a:visited {
color: green;
background-color: transparent;
text-decoration: none;
}
问题出在 ":link" 上,只需将其删除即可。
It's illogical.这不合逻辑。 If you define a color (pink) for a visited link, then all visited links becomes pink!如果您为访问过的链接定义颜色(粉红色),那么所有访问过的链接都会变成粉红色!
I guess you are trying to do a navbar and show active page right?我猜您正在尝试做一个导航栏并显示活动页面,对吗?
so check this example:所以检查这个例子:
http://www.w3schools.com/css/tryit.asp?filename=trycss_navbar_horizontal_black_active http://www.w3schools.com/css/tryit.asp?filename=trycss_navbar_horizontal_black_active
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.