html引用less样式,LESS 导入CSS选项关键字

描述

@import(css)会将文件导入为常规CSS,而不管文件扩展名。 这是在版本1.4.0 中发布的。

例子

以下示例演示如何在LESS文件中使用css关键字:

Import Options CSS

Welcome to Tutorialspoint

LESS is a CSS pre-processor that enables customizable, manageable and reusable style sheet for web site.

LESS is a CSS pre-processor that enables customizable, manageable and reusable style sheet for web site.

接下来,创建文件 style.less 。

style.less@import (css) "//www.w3cschool.cn/statics/demosource/css.txt";

.para_1 {

color: green;

.my_css;

}

.para_2 {

color: blue;

}

css.text.my_css {

font-family: "Comic Sans MS";

font-size: 20px;

}

您可以使用以下命令将 style.less 编译为 style.css :lessc style.less style.css

接下来执行上面的命令,它将用下面的代码自动创建 style.css 文件:

style.css.my_css {

font-family: "Comic Sans MS";

font-size: 20px;

}

.para_1 {

color: green;

font-family: "Comic Sans MS";

font-size: 20px;

}

.para_2 {

color: blue;

}

输出

让我们执行以下步骤,看看上面的代码如何工作:将上面的html代码保存在import_options_css.html文件中。

在浏览器中打开此HTML文件,将显示如下输出。

5257a30933085474c61376830f058a8f.png