微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

css – 浏览器不尊重a:visited {text-decoration:none; }

我无法从访问过的链接删除下划线.在我的计算机中,下面的小提琴在任何浏览器(当前版本的Chrome,Firefox和IE)中显示访问链接的黑色带下划线的文本.

a:link       { color: red;   text-decoration: underline; }
a:visited    { color: black; text-decoration: none;      }
<p><a href="http://www.nevervisited.com">This link is not visited.</a></p>
<p><a href="http://www.google.com">This is link is visited.</a></p>

这是Chrome访问链接的检查员.

我怀疑a:被访问的灰色与此有关,但this question关于灰色样式对我没有任何作用,尽管它帮助了许多其他人.

这些答案(this,this)表明规范并不关心子元素的文本装饰,当他们的祖先定义它时,但我不认为这是这种情况.我的< a> s没有下划线的父母,也没有使用伪元素,而是使用伪类.

此外,如果W3C说明,为什么Chrome会将访问链接应用于:链接

The two states [a:link and a:visited] are mutually exclusive.

也许这与隐藏网站私人信息的用户代理有关,比如W3C在之前的报价之后建议?这个:

Note. It is possible for style sheet authors to abuse the :link and :visited pseudo-classes to determine which sites a user has visited without the user’s consent.

UAs may therefore treat all links as unvisited links,or implement other measures to preserve the user’s privacy while rendering visited and unvisited links differently.

解决方法

您可以在大多数基于Webkit的浏览器(如Safari)或基于Blink(Chrome和Opera)的访问链接上应用的唯一CSS属性彩色的.其他任何东西都行不通.它与浏览器历史窃取有关.您可以从这里阅读更多相关信息:

http://seclists.org/fulldisclosure/2013/May/13

但是,您可以使用{text-decoration:none;}更改所有链接的样式.

选择器本身并不危险,但是如果你将它与J​​avascript的功能结合起来就像getComputedStyle()一样,事情会变得非常丑陋而丑陋我的意思是其他用户可以查看和阅读你的个人浏览器历史记录.

Mozilla(壁虎引擎)limited the selector properties颜色,背景颜色,边框 – * – 颜色.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。