无法覆盖为我的链接着色的用户代理样式表 [英] Can't override user agent stylesheet coloring my links

查看:49
本文介绍了无法覆盖为我的链接着色的用户代理样式表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

总是这些简单的问题困扰着我.

It's always these simple problems that snag me.

我正在构建一个非常简单的页面,我希望超链接根本没有特殊颜色(最初不是蓝色,访问时不是紫色)或带下划线.

I have a very simple page I'm building, and I want the hyperlinks to not be colored specially at all (not blue originally, not purple for visited) or underlined.

我之前在其他网站上做过这件事,只是简单地使用

I've done this in other sites before without issue simply by using

a, a:visited, a:hover, a:active {
    text-decoration: none;
    color: none;
}

但是,在此特定站点中,这并不能解决颜色问题,而下划线已成功删除.我什至尝试添加可怕的 !important 标签,但没有任何效果.

However, in this particular site, that's not doing the trick for the color, while the underline is successfully removed. I even tried adding the dreaded !important tag, with no effect.

此问题已在 Chrome、IE 11 和 Android (WebView) 上出现.

This issue has been seen on Chrome, IE 11, and Android (WebView).

当我使用 Chrome 的开发者控制台检查链接时,它会从 user agent stylesheet 中提取其 color 属性,具体来说:

When I inspect the links using Chrome's Developer console, it's pulling its color attribute from the user agent stylesheet, specifically:

a:-webkit-any-link {
    color: -webkit-link;
}

因此,我尝试通过将 a:-webkit-any-link 添加到我的标签列表中以将 color: none 属性应用于,在我的样式表中明确覆盖它,再次,没有效果.我还以各种组合添加了 a:any-linka:link ,但无济于事.

So I tried overriding this explicitly in my stylesheet by adding a:-webkit-any-link to my list of tags to apply the color: none attribute to, again, to no effect. I also added a:any-link and a:link in various combinations, to no avail.

对我忽略的明显解决方案的想法?

Thoughts on the obvious solution I'm overlooking?

推荐答案

正如评论所说 color:none; is not valid css.

As the comments said color:none; is not valid css.

这应该有效:

a, a:visited, a:hover, a:active {
    text-decoration: none;
    color: inherit;
}

这篇关于无法覆盖为我的链接着色的用户代理样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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