什么是正确的方式来处理css浏览器兼容性? [英] What is the correct way to deal with css browser compatibility?

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

问题描述

最好为每个用户代理有不同的CSS文件,还是最好使用只有某些浏览器可以看到的CSS Hacks?

Is it better to have a different CSS file for each user-agent or is it better to use CSS Hacks that only certain browsers can see?

最好的方法是编写可以工作的代码。

解决方案

推荐答案

在所有浏览器,而不需要浏览器的具体代码或css hacks。它当然不是那么容易完成,这就是为什么许多人使用其他方法。

The best is to write code that works in all browsers without the need of browser specific code or css hacks. It's of course not quite as easy to accomplish, which is why many people use the other methods.

关键是避免某些浏览器(非常经常的Internet Explorer)有问题。一个这样的事情是使用填充,而不是边距,因为IE不能正确处理边缘崩溃。

The key is to avoid things that some browsers (very often Internet Explorer) has problems with. One such thing is to use padding rather than margin, because IE doesn't handle margin collapsing correctly.

一些方法,在边界线的hacks是使用代码不会影响正常工作的浏览器,但会修复特定浏览器的问题。这可能是指定一个通常不应该需要的元素的高度,或在浮动元素上指定 display:inline

Some methods that is in the border line of being hacks is using code that doesn't affect browsers that work correctly, but fixes problems for a specific browser. That could be things like specifying a height for an element that normally shouldn't need one, or specifying display:inline on a floating element.

页面职位是一切有一些错误和建议的修复的例子。 (通常修复是某种类型的黑客,所以你当然也应该考虑如果你可以完全避免这个问题。)

The page Position is everything has examples of some bugs and suggested fixes. (Often the fix is some kind of hack, so you should of course also consider if you can avoid the problem altogether.)

这篇关于什么是正确的方式来处理css浏览器兼容性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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