我想创建一个带两个变量中的一个的Mixin,并根据传递的变量创建填充按钮或轮廓按钮。创建带和不带边框的Mixin
@include button-style($color: red);
// would result in
background-color: transparent;
color: red;
box-shadow: inset 0 0 0 1px red;
@include button-style($bg: red);
// would result in
background-color: red;
color: white;
有没有办法做到这一点?我在这里试图找出最简单的方法来实现这一目标。这是迄今为止我所拥有的。
@mixin button-style($bg: transparent, $color: white) {
background-color: $bg;
color: $color;
@if $color == 'white' {
box-shadow: inset 0 0 0 1px $color;
}
}
任何帮助表示赞赏。提前致谢!
实际上,如果你的作品写if语句为@if $ bg ==透明 - > http://sassmeister.com/gist/849233dd8093680c3f46 – KreaTief
谢谢duder!上面更新了答案。 – realph
不客气:) – KreaTief