【发布时间】:2017-02-10 16:16:51
【问题描述】:
问题
我创建了以下 mixin:
.type(@style;@mb) {
& when (@style = hero) {
margin-bottom: @mb;
font-size: 2.625rem;
line-height: 1.238095238;
}
}
现在这大部分都是我想要的。我遇到的问题是有时我想声明一个@mb 值,但很多时候我不会。在这些情况下,我希望为每个 @style 参数回退到预先确定的值。
例如:
- 对于
hero,@mb默认为margin-bottom: 1.25rem; - 对于
page,@mb默认为margin-bottom: 1.125rem; - 等
期望的结果
期望的结果如下:
.sample-class-01 { .type(hero); }
.sample-class-02 { .type(page,0); }
我会得到以下输出:
.sample-class-01 {
margin-bottom: 1.25rem;
font-size: 2.625rem;
line-height: 1.238095238;
}
.sample-class-02 {
margin-bottom: 0;
font-size: 2rem;
line-height: 1.3125;
}
如何创建这个 mixin?
【问题讨论】: