LESS 混合嵌套其他混合
LESS 混合嵌套其他混合
只要在另一个混合中定义了混合,它也可以作为返回值使用。
例子
<html> <head> <link rel = "stylesheet" href = "style.css" type = "text/css" /> <title>Mixin inside mixin</title> </head> <body> <h1>Welcome to Tutorialspoint</h1> <div class = "myclass"> <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*/
.outerMixin(@value) {
.nestedMixin() {
font-size: @value;
}
}
.myclass {
.outerMixin(30);
.nestedMixin();
}使用下面命令编译less文件
lessc style.less style.css
得到css
/*style.css*/
.myclass {
font-size: 30;
}输出
执行下面步骤:
保存上述代码到less_mixin_inside_mixin.html文件
打开浏览器观察结果
