1)
@mixin background-gradient($color1, $color2) {
background: linear-gradient(to right bottom, $color1 50%, $color2 50%);
&-small {
background: $color1;
}
}
.btn-red { @include background-gradient($red, $red-dark) }
.btn-blue { @include background-gradient($blue, $blue-dark) }
2)
.btn {
&-red {
background: linear-gradient(to right bottom, $red 50%, $red-dark 50%);
&-small {
background: $red;
}
}
&-blue {
background: linear-gradient(to right bottom, $blue 50%, $blue-dark 50%);
&-small {
background: $blue;
}
}
}
相同resoult:
.btn-red {
background: linear-gradient(to right bottom, red 50%, red 50%);
}
.btn-red-small {
background: red;
}
.btn-blue {
background: linear-gradient(to right bottom, blue 50%, blue 50%);
}
.btn-blue-small {
background: blue;
}
對不起,我想我的問題是有點混亂。我希望我的班級看起來像這樣:「btn btn-small btn-blue」 – passatgt