目录

不输出Mixin(Not Outputting the Mixin)

描述 (Description)

可以创建一个mixin,只需将括号放在后面就可以使其在输出中消失。

例子 (Example)

以下示例演示了在LESS文件中使用mixin -

<html>
   <head>
      <link rel = "stylesheet" href = "style.css" type = "text/css" />
      <title>LESS Mixins</title>
   </head>
   <body>
      <div class = "myclass">
         <h1>Welcome to IoWiki</h1>
         <p>LESS is a CSS pre-processor that enables customizable, 
         manageable and reusable style sheet for web site.</p>
      </div>
   </body>
</html>

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

style.less

.a() {
   padding-left: 100px;
}
.myclass {
   background : #64d9c0;
   .a;
}

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

lessc style.less style.css

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

style.css

.myclass {
   background: #64d9c0;
   padding-left: 100px;
}

输出 (Output)

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

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

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

LESS Mixins
↑回到顶部↑
WIKI教程 @2018