简体   繁体   中英

Linking a CSS Folder rather than individual Files?

只是好奇,在这个主题上找不到任何具体的东西,但是可以接受,而不是将10-20个CSS文件单独链接到一个页面,您可以链接一个文件夹,它包含该文件夹中的所有CSS文件吗?尝试减少我页面上的代码量。

Combine your CSS files. Linking broadly to an entire directory is not really feasible.

Unfortunately you can't use folder references in your markup, but using CSS preprocessors such as LESS, SASS you definitely can eliminate having to load too many files by compiling them together.

Check out these:

http://lesscss.org/

http://sass-lang.com/

And the real awesomeness:

http://compass-style.org/

There are very easy to set-up tools as well such as Scout:

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

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/

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

Combine them and minify them with something like YUI compressor http://developer.yahoo.com/yui/compressor/ . Although that can be a pain if you are modifying your CSS often.

Or if you are in the .NET environment you can use Microsoft.Web.Optimization to auto bundle & minify entire folders of js and css.

It's less of an issue about the amount of code on your page, and more about the amount of HTTP Requests.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM