【发布时间】:2015-01-09 20:45:31
【问题描述】:
我正在尝试创建一个 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;
}
}
感谢任何帮助。提前致谢!
【问题讨论】: