如何为Mozilla Firefox编写单独的样式表 [英] How to write separate style sheet for Mozilla Firefox

查看:252
本文介绍了如何为Mozilla Firefox编写单独的样式表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为Mozilla Firefox编写单独的样式表

How to write separate style sheet for Mozilla Firefox

推荐答案

这个规则的一个例外是,如果你需要支持旧版本的IE浏览器,它们有一些与其他浏览器不兼容,不能轻易地以其他方式解决。但是即使对于IE,你需要做到这一点的情况是很少和很远的。对于Firefox,它们几乎为零。

The one exception to this rule is if you need to support older versions of IE, which have a few incompatibilities with other browsers that can't easily be resolved in other ways. But even for IE the cases where you'll need to do this are few and far between. For Firefox they're virtually nil.

如果你确实需要区分浏览器,由于不同的功能,一个更好的解决方案是使用功能检测,而不是浏览器检测解决差异。

If you do need to distinguish between browsers due to differing features, a far better solution is to use feature detection rather than browser detection to resolve the differences.

一个很好的解决方案是使用 Modernizr 。这是一个Javascript库,(其中包括)添加一堆类到您的HTML页面的body标记。它添加的类将根据您的浏览器支持的功能而有所不同。这允许你编写引用这些类的样式表和JS代码,所以你可以根据浏览器的功能有不同的行为。

One very good solution to this is to use Modernizr. This is a Javascript library which (among other things) adds a bunch of classes to the body tag of your HTML page. The classes it adds will be different according to the features that are supported by your browser. This allows you to write stylesheets and JS code that reference these classes, so you can have different behaviour according to the features in your browser.

如果你仍然认为browser-检测是一个好主意,以下是一些阅读材料: http:// css- tricks.com/browser-detection-is-bad/

If you still think that browser-detection is a good idea, here is some reading material for you: http://css-tricks.com/browser-detection-is-bad/

希望有所帮助。

这篇关于如何为Mozilla Firefox编写单独的样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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