背景图像:for :visited links? [英] background-image: for :visited links?

查看:9
本文介绍了背景图像:for :visited links?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将 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.

推荐答案

根据大多数规范,您的代码是正确的.但是,许多浏览器会考虑访问链接上的背景图片可能侵犯用户隐私,所以他们不允许这样做.

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.

这篇关于背景图像:for :visited links?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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