我想在Bootstrap 4中创建一个带有白色(#fff)文本颜色的新按钮样式。 Mixin button-variant
根据背景颜色自动设置文本颜色。如何在不修改_buttons.scss
?
custom.scss
.my_button {
@include button-variant(HOW TO SET TEXT COLOR TO WHITE?);
}
_buttons.scss
@mixin button-variant($background, $border, $hover-background: darken($background, 7.5%), $hover-border: darken($border, 10%), $active-background: darken($background, 10%), $active-border: darken($border, 12.5%)) {
color: color-yiq($background);
@include gradient-bg($background);
border-color: $border;
@include box-shadow($btn-box-shadow);
@include hover {
color: color-yiq($hover-background);
@include gradient-bg($hover-background);
border-color: $hover-border;
}
答案 0 :(得分:6)
这类似于:How to create new set of color styles in Bootstrap 4 with sass
您需要使用@include作为自定义按钮,设置color:
,然后传入相应的mixin参数...
.btn-custom {
@include button-variant(pink, red, red, #444, #333, red);
color: #fff;
}