Html <head> 部分中包含较少的 css 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18335299/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Less css file include in <head> section
提问by Moue Mita
Which files are needed to include in <head>
section for less css. At less official site , i have just seen that they have told to include .less and .js file. But it is not working without .css file.
哪些文件需要包含在<head>
节中以减少 css。在不太正式的网站上,我刚刚看到他们告诉要包含 .less 和 .js 文件。但是没有 .css 文件它就不能工作。
回答by Henri Hietala
Referring to LESS documentation (http://lesscss.org/#client-side-usage):
参考 LESS 文档(http://lesscss.org/#client-side-usage):
Link your .less stylesheets with the rel set to “stylesheet/less”:
将 .less 样式表与 rel 设置为“stylesheet/less”:
<link rel="stylesheet/less" type="text/css" href="styles.less" />
Then download less.js from the top of the page, and include it in the <head>
element of your page, like so:
然后从页面顶部下载less.js,并将其包含在<head>
页面元素中,如下所示:
<script src="less.js" type="text/javascript"></script>
Make sure you include your stylesheets before the script.
确保在脚本之前包含样式表。
This method will cause the less-file act as a regular css-file so no additional files are needed.
此方法将导致 less-file 充当常规 css 文件,因此不需要其他文件。
This is not a good practice for production environments though. You should compile your less-file to css-file and include it in your <head>
-section as is without any less- or js-files.
但这对于生产环境来说并不是一个好的做法。您应该将您的 less-file 编译为 css-file 并将其按<head>
原样包含在您的-section 中,而没有任何 less- 或 js 文件。
回答by Moue Mita
@import "styles.less";
OR
或者
@import "styles";
its from ur CSS file.. you just need to include it like
它来自你的 CSS 文件 .. 你只需要像这样包含它
<link rel="stylesheet/less" type="text/css" href="styles.less" />