这是一个《精通CSS》书里的一个例子,代码:
- HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Visited Links</title> <style type="text/css"> <!-- /* pretty stuff ================================== */ body { font-family: "Myriad Pro", Frutiger, "Lucida Grande", "Lucida Sans", "Lucida Sans Unicode", Verdana, sans-serif; font-size: 1em; } /* visited links ================================== */ ul { list-style:none; } li { margin: 5px 0; } li a { display: block; width: 300px; height: 30px; line-height: 30px; color: #000; text-decoration: none; background: #94B8E9 url(images/visited.gif) no-repeat left top; text-indent: 10px; } li a:visited { background-position: right top; } --> </style> </head> <body> <ul> <li><a href="http://www.andybudd.com/">Andy Budd's Blogography</a></li> <li><a href="http://www.stuffandnonsense.co.uk/">Stuff and Nonsense</a></li> <li><a href="http://www.hicksdesign.co.uk/journal/">Hicks Design</a></li> <li><a href="http://www.clagnut.com/">Clagnut</a></li> <li><a href="http://www.htmldog.com/">HTML Dog</a></li> <li><a href="http://adactio.com/journal/">Adactio</a></li> <li><a href="http://www.allinthehead.com/">All In The Head</a></li> <li><a href="http://www.markboulton.co.uk/journal/">Mark Boulton</a></li> <li><a href="http://www.ian-lloyd.com/">Ian Lloyd</a></li> </ul> </body> </html>
背景图片images/visited.gif是这样的,
当访问链接被访问后,对应的背景图像重新定位background-position: right top,从而表示这个链接已经被访问过了。
但问题是在chrome 15.0.874.106、safari 5.1.1中没有预期的效果,IE 7、firefox 3.6都没有问题,谁知道这是什么原因,帮忙看一下,谢谢!
------解决方案--------------------
li a:visited {
background: #94B8E9 url(images/visited.gif) no-repeat;
background-position: right top;
}
这样试试