什么是最好的办法来处理IE兼容性问题? [英] What is the best way to deal with IE compatibility issue?

查看:106
本文介绍了什么是最好的办法来处理IE兼容性问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为一切都同意我的看法,但IE是最不兼容的浏览器。

I think everything agrees with me here, but IE is the most incompatible browser out there.

我使用不同的css文件处理每个版本的不兼容性,以正确显示它。

I deal with ie's incompatibility using different particular css files for each version, to display it correctly?

有更好的方法?

推荐答案

使用不同的CSS文件与< !- [if IE]过滤器是你可以编写100%兼容的CSS,而黑客会使你的CSS无效。

The advantage of using different CSS files with <!--[if IE]> filters is that you can write 100% compliant CSS, whereas hacks will make your CSS invalid.

另一方面,使用CSS hacks的优势只有一个CSS文件是下载效率。

On the other hand, the advantage of using CSS hacks to have only one CSS file is download efficiency.

仍然,我喜欢过滤器。使用下面的范例帮助我保持我的浏览器特定的CSS组织,利用级联以及等效的特异性是我找到处理浏览器不一致的最简单的方法。不要忘记,您还可以在这些过滤器中加入特定于IE的JavaScript,以增强您的IE体验。

Still, I prefer filters. Using the paradigm below helps me keep my browser specific CSS organized, and leveraging the "cascade" along with equivalent "specificity" is the easiest way that I have found to deal with browser inconsistencies. Don't forget you can also include javascript specific to IE in these filters to juice up your IE experience.


<link id="stylesheet1" rel="stylesheet" href="css/style.css" type="text/css" media="all" />
<!--[if IE]>
<link id="stylesheet2" rel="stylesheet" href="css/ie.css" type="text/css" media="all" />
<![endif]--> 
<!--[if lte IE 6]>
<link id="stylesheet3" rel="stylesheet" href="css/ie6.css" type="text/css" media="all" />
<![endif]-->

这个过滤器范例的另一个了不起的是,你隔离为老化浏览器编写的代码,天变得过时。例如,有人关心IE 5了吗?这些文件不会减缓任何事情,因为它们只是根据需要下载,而且随着时间的推移,它们不太需要。

The other great thing about this filter paradigm is that you isolate your code written for aging browsers that will one day become obsolete. For example, does anyone care about IE 5 anymore? Those files aren't slowing anything down, because they are only downloaded on an as-needed basis, and they are less needed over time. I'd rather have it this way versus having my obsolete code intertwined with my standards compliant code.

但是,除了IE之外的浏览器,例如Safari或Firefox,还有什么其他的呢?我想用这种方式,而不是将我的过时的代码与我的标准兼容的代码交织在一起。好吧,试着写的CSS代码,在Chrome / Safari / Firefox的工作原理相同,我很少需要一个特定的黑客其中一个,但对于一些东西,我使用浏览器特定的CSS扩展。

However, what about browsers other than IE such as Safari or Firefox? Well, try to write CSS code that works the same accross Chrome/Safari/Firefox and I rarely need a specific hack for one of them, but for some stuff I have used browser specific CSS extensions.

另一个选项是JavaScript浏览器选择器:

Another option is javascript browser selectors:

http://rafael.adm.br/css_browser_selector/

最后,我简要地看了一下SO他们似乎没有使用IE过滤器。他们有一个CSS文件,他们聪明地托管在一个cookieless域的性能:

Lastly, I briefly looked at S.O. and they don't seem to be using IE filters. They have one CSS file, which they have cleverly hosted on a cookieless domain for performance:

http://sstatic.net/

这篇关于什么是最好的办法来处理IE兼容性问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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