IE8忽略“过滤器” CSS样式 [英] IE8 ignores "filter" CSS styles
问题描述
我有一个页面使用 AlphaImageLoader
CSS过滤器为IE8:
I have a page which uses the AlphaImageLoader
CSS filter for IE8 like so:
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src ='/ images / thing.png',sizingMethod ='scale');
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/thing.png', sizingMethod='scale');
$ b b
在我的测试IE8(Windows XP,出厂设置),一切都很好。然而,客户收到了一个声称也在使用IE8的人的截图,看起来像浏览器完全忽略了过滤器
指令。在通过条件注释加载的IE特定样式表中的所有其他样式似乎工作。
In my test IE8 (Windows XP, factory settings), everything is fine. The client however received a screenshot from someone claiming to be also using IE8 which looks like the browser completely ignores the filter
directive. All other styles in the IE-specific stylesheet loaded via conditional comments appear to be working. Is there any setting in IE or in Windows which would be causing this?
谢谢,Simon
推荐答案
IE8用 -ms-filter
替换了过滤器
。
如果您要支持所有版本的IE,您需要提供这两种样式。
If you want to support all versions of IE, you need to provide both of these styles.
-ms-filter
稍微不同于过滤器
:
-
现在,所有过滤器都指定了完整的
progid
字符串(根据您的示例,但某些过滤器可以使用较短的语法指定)。
All filters are now specified with their full
progid
string (as per your example, but some filters could previously be specified with a shorter syntax).
-ms-filter
的值必须用引号括起来。这是为了防止它是无效的CSS语法(因为它包含冒号后 progid
它是无效的CSS;在坏的情况下已知会导致其他浏览器中的解析错误阻止他们正确地阅读CSS文件的其余部分)。
The value for -ms-filter
must be enclosed in quotes. This is to prevent it from being invalid CSS syntax (since it contains a colon after progid
it is invalid CSS; in bad cases has been known to cause parsing errors in other browsers that stop them from reading the rest of the CSS file properly).
因此,在您的示例中,您需要以下样式:
So in your example, you need the following styles:
.myelement {
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/thing.png', sizingMethod='scale');
-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/thing.png', sizingMethod='scale')";
}
请注意,IE9已放弃对 filter
和 -ms-filter
,以支持等效标准CSS3属性。
Note that IE9 has dropped support for both filter
and -ms-filter
, in favour of the equivalient standard CSS3 properties.
这有助于。
这篇关于IE8忽略“过滤器” CSS样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!