【问题标题】:Why doesn't my a:visited style work in Chrome or IE?为什么我的 a:visited 样式在 Chrome 或 IE 中不起作用?
【发布时间】:2020-03-16 02:54:23
【问题描述】:

我正在使用一个简单的 HTML 选择器来更改访问链接的颜色。这适用于 Edge 和 Firefox,但不适用于 Chrome 和 IE。任何提示都会很棒。

a:visited {
  color: pink !important;
}
<a href="https://www.w3schools.com">W3Sschools</a>
<a href="http://www.wikipedia.org">Wikipedia</a>

<p><b>Note:</b> The :link selector style links to pages you have not visited yet.</p>

【问题讨论】:

  • 为我在 Chrome 中工作。
  • 不是重复的(显然),因为这确实在 Chrome 中工作。应关闭为“无法复制”(基于提供的示例)。
  • 您是否也为a 设置了颜色?
  • 对我来说,它在 chrome 中的行为与描述的相同。当open in new tab 时有效

标签: html css css-selectors


【解决方案1】:

当为&lt;a&gt; 元素设置像:visited 这样的伪类样式时,最好明确地设置所有元素 的样式,这样您就不会遇到任何样式表冲突:

  • a:link
  • a:visited
  • a:hover
  • a:active

您可以通过助记符记住正确的顺序:LoVe HAte

【讨论】:

  • 适用于大多数链接,但在新标签页中打开的链接除外,它在 IE 11 和 Chrome 中具有 target=_blank
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2010-12-12
  • 1970-01-01
  • 1970-01-01
  • 2011-02-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多