只导入一个页面的LESS文件 [英] Import LESS file only for one page
本文介绍了只导入一个页面的LESS文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有主要的 all.less
文件,其中包括所有其他较少的文件
I have main all.less
file, where I'm including all other less files
/ p>
e.g.
@import "scaffolding.less";
@import "type.less";
@import "code.less";
@import "grid.less";
@import "homepage.less";
所以我的问题是。
只能在首页中导入homepage.less
(导入 all.less
)。
Is it possible to get"homepage.less"
only in homepage (importing it in all.less
).
请注意,我不想直接附加在html档案中。
Please Note that I don't want to attach it directly in the html file.
p>
推荐答案
在您的首页上使用:
<body class="homepage">
然后在你的Less文件中:
And then in your Less files:
.homepage {
@import "homepage.less";
}
上述内容仍然会在一个文件中编译所有代码。您编译的CSS代码会有更多字节,但您可以为所有网页缓存相同的文件。
The above still compiles all your code in a single file. Your compiled CSS code will have a larger number of bytes, but you can cache the same file for all your pages.
这篇关于只导入一个页面的LESS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文