如何在Bootstrap 4 和Sass 中设置自定义按钮文本颜色?
How to set custom button text color in Bootstrap 4 and Sass?
我想在 Bootstrap 4 中创建一个新的按钮样式,文本颜色为白色 (#fff)。 Mixin button-variant
根据背景颜色自动设置文本颜色。如何在不修改的情况下同时使用此 mixin 和设置颜色 _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;
}
这类似于:
您需要为自定义按钮使用@include,设置color:
,并传入适当的混合参数...
.btn-custom {
@include button-variant(pink, red, red, #444, #333, red);
color: #fff;
}
https://www.codeply.com/go/EHwnjvUXac
相关:
我想在 Bootstrap 4 中创建一个新的按钮样式,文本颜色为白色 (#fff)。 Mixin button-variant
根据背景颜色自动设置文本颜色。如何在不修改的情况下同时使用此 mixin 和设置颜色 _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;
}
这类似于:
您需要为自定义按钮使用@include,设置color:
,并传入适当的混合参数...
.btn-custom {
@include button-variant(pink, red, red, #444, #333, red);
color: #fff;
}
https://www.codeply.com/go/EHwnjvUXac
相关: