gpt4 book ai didi

javascript - Internet Explorer 的 CSS 表达式与过滤器和 Javascript

转载 作者:行者123 更新时间:2023-11-28 12:26:36 25 4
gpt4 key购买 nike

CSS 表达式和 CSS 过滤器有什么区别?

两者都对页面速度不利吗?

如果某些东西可以在其他浏览器中用纯 CSS 实现,但对于 IE 只能通过 CSS 表达式或 CSS 过滤器或 Javascript 实现。如果我们关心页面速度,那么我们是否应该始终使用 Javascript。

Javascript 的渲染速度会比 CSS FilterExpression 解决方案快吗?


Pekka 回答后更新

好的,所以应该避免使用 CSS 表达式,这很清楚。

现在我想了解过滤器

过滤器示例

#myElement {
opacity: .4; /* other browsers */
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=40); /* this works in IE6, IE7, and IE8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=40)"; /* this works in IE8 only */
}

要在 IE6 中获得 PNG 透明度和在 IE 6、7、8 中获得一些 CSS 3 效果,我们可以使用 CSS IE Filters

http://www.smashingmagazine.com/2010/04/28/css3-solutions-for-internet-explorer/

还有一些可用的 Javascript 替代品。

Javascript 的渲染速度会比 CSS Filter 快吗?

注意 filter 属性不是有效的 CSS

最佳答案

在旧版本的 IE 中,如果您可以选择使用 CSS 过滤器或 CSS 表达式,则过滤器是更好的选择。

但是,我想不出有哪个场景可以让您选择过滤器表达式。

您应该更喜欢普通的 Javascript 而不是表达式,因为表达式不断地 被求值,例如在 mousemove 上。使用纯 Javascript,您可以控制代码何时运行,例如 onloadonresize

查看 Google document on the subject :

CSS expressions degrade rendering performance; replacing them with alternatives will improve browser rendering for IE users.

Note: This best practices in this section apply only to Internet Explorer 5 through 7, which support CSS expressions. CSS expressions are deprecated in Internet Explorer 8, and not supported by other browsers.


过滤器在 IE 中使用的东西,通常没有办法替换它们。

没有办法改为“使用 Javascript”,因为 Javascript 只会动态应用过滤器。透明度和 rgba 渐变滤镜解决方法就是这种情况。


回应您的编辑:

and there are also some Javascript alternative available.

Will Javascript be quicker in rendering than CSS Filter ?

article你链接到,没有一个解决方法有 filter 解决方案 Javascript 解决方案(那些有的只是自动应用相同的 filter,因为方便)。

关于javascript - Internet Explorer 的 CSS 表达式与过滤器和 Javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4838915/

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