LESS - 不输出 Mixin
说明
可以创建一个 mixin,只需在其后放置括号即可使其在输出中消失。
示例
以下示例演示了在 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 Tutorialspoint</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;
}
输出
按照以下步骤查看上述代码的工作原理 −
将上述 html 代码保存在 less_mixin_not_outputting.html 文件中。
在浏览器中打开此 HTML 文件,将显示以下输出。

less_mixins.html