问题描述
我有一个网站,我有多个css样式表打印,电视,屏幕,掌上电脑等...
i have a website and i have multiple css style sheet for print, tv, screen, handheld etc...
我想知道这些方法(性能,可用性...)
i want to know which one of these method is better to use (performance, usability, etc...)
<link href="all.css" media="all" type="text/css" />
<link href="handheld.css" media="handheld" type="text/css" />
<link href="tv_print.css" media="tv, print" type="text/css" />
或
<style type="text/css">
@import url("all.css") all;
@import url("handheld.css") handheld;
@import url("tv_print.css") tv, print;
</style>
谢谢
推荐答案
第一种方法(链接)是最好的。
The first method (link) is the best.
主要原因是IE 6,7和8中有一个错误大约9或更高)意味着当您使用@import与链接时,文件是串行加载而不是并行加载。当使用多个样式表时,这可以减缓很多事情。
The main reason is that there is a bug in IE 6,7 and 8 (not sure about 9 or higher) means that when you use @import in conjunction with link the files are loading in series rather than in parallel. This can slow things down a lot when using more than one style sheet.
只是使用@import下载系列,但是顺序是不能保证的,
Just using @import downloads in series, but the order isn't guaranteed, meaning that if there is a reset for instance, that may or may not be applied first.
这篇文章有一个很好的总结:
This article has a good summary: http://www.stevesouders.com/blog/2009/04/09/dont-use-import/
这篇关于使用`< link>`或`@ import`包含CSS - 更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!