我有一个适用于 filter:none;
的 IE7 特定样式表我无权访问此文件,因此不能简单地删除该行。我需要通过 CSS 以某种方式覆盖它,以忽略正在设置的 filter:none;
。
我已经尝试使用 filter:;
filter: -;
和 filter: !important;
这应该会导致 filter 属性无效, 但过滤器仍在设置中。
是否可以在不删除 IE7 特定样式表中的行或不使用 javascript/jquery 的情况下执行此操作?
答案:
为了解决我的具体问题,不可能简单地覆盖 filter
与我所要求的 null
等效。正如下面的答案所暗示的那样,必须通过将过滤器直接应用于我想要覆盖的位置来覆盖它。
IE7 特定样式表:
.div.example {
filter:none;
}
被覆盖: 通用样式表:
.div.example {
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#7F000000,endColorstr=#7F000000);
}
最佳答案
摘自 this answer
Microsoft introduced -ms-filter to make Internet Explorer more standards-compliant (CSS 2.1 requires vendor extensions to have vendor prefix). As the syntax of original filter property is not CSS 2.1 compliant, IE8+ requires the value of the -ms-filter property to be enclosed in quotation marks.
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(enabled=false)" /* IE 8+ */;
filter: none !important; /* IE 7 and the rest of the world */
如您所说,您需要覆盖现有样式,因此附加 !important
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(enabled=false) !important";
如果您想知道,此 Microsoft (-ms) 供应商前缀是需要引号。如您所见,此用例使用 MS 的渐变,将其插入您希望覆盖的任何过滤器属性。
关于html - 如何覆盖过滤器 :none in CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23739429/