background-image:for:访问的链接? [英] background-image: for :visited links?

查看:199
本文介绍了background-image:for:访问的链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以为访问过的链接添加background-image:属性?

Is it possible to add the background-image: property to visited links?

 a.coolLinks:visited{
     background-image:url("http://www.ledr.com/colours/black.jpg");
}

感谢

编辑:所以这似乎是一个安全漏洞,这就是为什么它不能做。没有迹象表明浏览器阻止了此css样式。

So it appears that this is a security vulnerability and this is why it cannot be done. There was no indication that the browsers were blocking this css style.

推荐答案

您的代码根据大多数规格是正确的。但是,许多浏览器会考虑访问过的链接上的背景图片a

Your code is correct according to most specifications. However, many browsers consider background images on visited links a potential violation of user's privacy, so they do not allow it.

观察此示例:

<p><a href="/unvisited">Unvisited link</a></p>

<p><a href="http://jsfiddle.net/">Visited Link</a></p>

<style>
a {
  background:red url("http://placekitten.com/100/101?image=2") center center no-repeat;
  display: block;
  height: 200px;
  width: 200px;
  overflow: hidden;
  text-align: center;
  background-color: red;
}

a:visited {
  background:blue url("http://placekitten.com/100/100?image=1") center center no-repeat;
}
</style>

(另请参阅 http://jsfiddle.net/Yq5GY/1/ )。 Firefox忽略被访问链接的背景图像声明,并且从不显示独奏小猫。您可以使用背景颜色进行区分。无论如何,只依靠图像是不好的可用性。

(Also at http://jsfiddle.net/Yq5GY/1/). Firefox ignores the background image declaration for visited links, and never displays the solo kitten. You can do some differentiation with background color. It's bad usability to rely on images alone, anyhow.

这篇关于background-image:for:访问的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆