将CSS3PIE .htc文件加载为其他浏览器,即使他们不需要? [英] Will CSS3PIE .htc file load for other browsers even they don't need?

查看:248
本文介绍了将CSS3PIE .htc文件加载为其他浏览器,即使他们不需要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 CSS3Pie 在IE中创建使用无效CSS属性的圆角

I'm using CSS3Pie to make round corners in IE which uses invalid CSS property

behavior: url(/PIE.htc);

如果我保持这个声明在我的主CSS,其他浏览器加载这个.htc文件,

If i keep this declarition in my main CSS will other browsers load this .htc file even they don't need this or only IE will load this file?

有什么好处保留行为:url(/PIE.htc);

Is there any benefit to keep behavior: url(/PIE.htc);is seperate IE conditional stylesheet in terms of performance?

<!--[if lt IE 9]>
        <link rel="stylesheet" type="text/css" href="ie8-and-down.css" />
<![endif]-->

整个代码如下

border: 1px solid #696;
padding: 60px 0;
text-align: center; width: 200px;
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
background: #EEFF99;
behavior: url(/PIE.htc);


推荐答案

规范说浏览器完全忽略其属性名称无法识别的声明。这意味着,理论上,由于行为是一个仅IE属性,不应该解析 url()并且该文件不是由IE之外的浏览器下载的。

The spec says that browsers are to completely ignore declarations whose property names they don't recognize. This means, theoretically, that since behavior is an IE-only property, the url() should not be parsed, and the file not be downloaded by browsers other than IE.

我在IE9和Firefox 4上运行测试,加载 CSS3 PIE标签演示,这里是F12开发工具和Firebug在其网络选项卡中分别显示。注意,Firebug不报告请求 /PIE.htc 文件的尝试。这意味着Firefox没有加载文件,即使它是在样式表中声明的,因为它不能识别行为属性。

I ran a test on IE9 and Firefox 4, loading the CSS3 PIE tabs demo, and here's what F12 Developer Tools and Firebug show respectively in their network tabs. Notice that Firebug reports no attempt to request the /PIE.htc file. That means Firefox didn't load the file even though it was declared in your stylesheet, because it doesn't recognize the behavior property.

IE9(F12开发人员工具)

Firefox 4(Firebug)

我会移动的唯一原因如果我不想用非标准属性和/或黑客来污染我的主样式表,那么属性到带有条件注释的仅IE样式表。

The only reason I'd move that property to an IE-only stylesheet with conditional comments is if I don't want to pollute my main stylesheet with non-standard properties and/or hacks.

这篇关于将CSS3PIE .htc文件加载为其他浏览器,即使他们不需要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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