1

Just curious, couldn't really find any specific stuff on this topic but would it be acceptable rather than linking 10-20 css files to a page individually you could link a folder and it would encompass all the css files that are in that folder?Trying to cut back on the amount of code on my pages.

4

5 回答 5

3

合并您的 CSS 文件。广泛链接到整个目录实际上并不可行。

于 2012-11-09T19:28:11.500 回答
3

不幸的是,您不能在标记中使用文件夹引用,但是使用 CSS 预处理器(例如 LESS、SASS),您绝对可以通过将它们编译在一起来消除加载过多文件的麻烦。

看看这些:

http://lesscss.org/

http://sass-lang.com/

真正令人敬畏的是:

http://compass-style.org/

还有非常容易设置的工具,例如 Scout:

http://mhs.github.com/scout-app/

于 2012-11-09T19:29:38.173 回答
2

Use @import to link to a single css that has a list of all the CSS files.

However, this is not good from a performance stand point.

http://www.stevesouders.com/blog/2009/04/09/dont-use-import/

于 2012-11-09T19:33:23.610 回答
1

您可以制作一个导入所有其他文档的 css 文档(使用@import url("import1.css");),因此您只需调用基本 css 文档。

于 2012-11-09T19:29:23.480 回答
0

将它们组合起来并用 YUI 压缩器http://developer.yahoo.com/yui/compressor/之类的东西缩小它们。尽管如果您经常修改 CSS,这可能会很痛苦。

或者,如果您在 .NET 环境中,您可以使用 Microsoft.Web.Optimization 自动捆绑和缩小整个 js 和 css 文件夹。

页面上的代码量不是问题,更多的是 HTTP 请求的数量。

于 2012-11-09T19:56:50.813 回答