最近在学习bootstrap,看到 http://v3.bootcss.com/ 经常会提起mixin, bootstrap-3.3.5 中的less/mixins中有大量的mixin,不知道在实际项目中该如何使用?
以清楚浮动.clearfix()为例。自己想到了一种方法:
在单独的.less中,添加如下代码
// Mixin
.clearfix() {
&:before,
&:after {
content: " ";
display: table;
}
&:after {
clear: both;
}
}
// Usage
.container {
.clearfix();
}
因为没有在项目中用过,所以以上都是理论,不知道实际中会怎么处理?
bootstrap是使用的less来编译CSS的,所以你可以去Less的官网看看
附上链接:less语言特性