gpt4 book ai didi

css - 浏览器不接受 :visited { text-decoration: none; }

转载 作者:技术小花猫 更新时间:2023-10-29 11:18:51 25 4
gpt4 key购买 nike

我无法从已访问的链接中删除下划线。在我的电脑中,下面的 Fiddle 在任何浏览器(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:visited变灰与此有关,但是this question关于灰色样式对我没有任何帮助,尽管它帮助了许多其他人。

这些答案( thisthis )表明规范不关心子元素的 text-decoration当他们的祖先定义它时,但我认为这里不是这种情况。我的<a> s 没有带下划线的 parent ,我也不是使用伪元素,而是伪

还有,为什么Chrome应用a:link到访问过的链接,如果 W3C

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

也许这与用户代理从网站隐藏私有(private)信息有关,就像 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)中,您可以在 a:visited 链接上应用的唯一 CSS 属性是 color .别的什么都行不通。它与浏览器历史记录窃取有关。您可以从这里阅读更多相关信息:

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

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

选择器本身并不危险,但如果将它与 Javascript 的函数结合使用,例如 getComputedStyle()事情可能会变得非常丑陋,我所说的丑陋是指其他用户可以查看和阅读您的个人浏览器历史记录。

Mozilla(Gecko 引擎)limited the selector propertiescolor, background-color, border-*-color.

关于css - 浏览器不接受 :visited { text-decoration: none; },我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31194553/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com