目录

reference

描述 (Description)

@import (reference)用于导入外部文件,但不会将导入的样式添加到已编译的CSS文件中。 这是在version 1.5.0中发布的。

例子 (Example)

以下示例演示了在LESS文件中使用reference关键字 -

<html>
   <head>
     <link rel = "stylesheet" href = "style.css" type = "text/css" />
     <title>Import Options Reference</title>
   </head>
   <body>
      <h1>Welcome to IoWiki</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 (reference) "http://www.iowiki.com/less/import_reference.less";
p {
   .style1;
}

以下代码将import_reference.less文件从https://www.iowiki.com/less/import_reference.less路径导入import_reference.less文件 -

import_reference.less

.style1 {
   color: #A0A0A0;
   font-family: "Comic Sans MS";
   font-size: 20px;
}

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

lessc style.less style.css

执行上面的命令; 它将使用以下代码自动创建style.css文件 -

style.css

p {
   color: #A0A0A0;
   font-family: "Comic Sans MS";
   font-size: 20px;
}

输出 (Output)

请按照以下步骤查看上述代码的工作原理 -

  • 将上述html代码保存在import_options_reference.html文件中。

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

少导入选项参考

reference具有extend方法,该方法在引用@import语句的位置@import新选择器并将其标记为not referenced 。 有关更多信息, 请单击此处

↑回到顶部↑
WIKI教程 @2018