描述
它用于导入LESS或CSS文件的内容.
示例
以下示例演示了在LESS文件中使用导入 :
Less Importing Example using Importing
LESS enables customizable, manageable and reusable style sheet for web site.
It allows reusing CSS code and writing LESS code with same semantics.
LESS supports creating cleaner, cross-browser friendly CSS faster and easier.
现在创建 myfile.less 文件.
myfile.less
.myclass { color: #FF8000;}.myclass1 { color: #5882FA;}
现在创建 style.less 文件.
样式.less
@import"http://www.it1352.com/less/myfile.less"; .myclass2 { color:#FF0000; }
将 myfile.less 文件导入 style.less 来自路径 https://www.it1352.com/less/myfile.less
您可以使用以下命令将 style.less 文件编译为 style.css ;
lessc style.less style.css
执行上述命令;它将使用以下代码自动创建 style.css 文件;
style.css
.myclass { color: #FF8000;}.myclass1 { color: #5882FA;}.myclass2 { color: #FF0000;}
输出
按照以下步骤查看上述代码的工作原理;
将上述html代码保存在 imports.html 文件中.
在浏览器中打开此HTML文件,将显示以下输出.