扫码一下
查看教程更方便
less 导入用于导入 less 或 css 文件的内容。
下面的例子演示了less文件中导入的使用
importing.html
迹忆客(jiyik.com) - less 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。
style.less
@import "myfile.less"; .myclass2 { color: #ff0000; }
myfile.less 文件将导入到 style.less
我们可以使用以下命令将 style.less 文件编译为 style.css
$ lessc style.less style.css
执行上述命令; 它将使用以下代码自动创建 style.css 文件
style.css
.myclass { color: #ff8000; } .myclass1 { color: #5882fa; } .myclass2 { color: #ff0000; }
按照以下步骤查看上述代码的工作原理