[英]Change default color of Bootstrap btn-primary class
I know I can simply do this in my SCSS file.我知道我可以在我的 SCSS 文件中简单地做到这一点。 But I would like to know the correct way to do it via customizing the actual Bootstrap colors.
但我想通过自定义实际的 Bootstrap colors 来了解正确的方法。 I have already figured out how to change background colors on the buttons.
我已经想出了如何更改按钮上的背景 colors。
I created a custom-bootstrap.scss
file in which I modified the $primary
and $danger
variables and then imported Bootstrap.我创建了一个
custom-bootstrap.scss
文件,在其中修改了$primary
和$danger
变量,然后导入了 Bootstrap。 custom-bootstrap.scss:
// Override default variables before the import
$primary: #48BF91;
$danger: #CF6676;
// Import Bootstrap and its default variables
@import '~bootstrap/scss/bootstrap.scss';
This is my inspector showing where it sets the text color to black from the _buttons.scss
file.这是我的检查器,显示了它在
_buttons.scss
文件中将文本颜色设置为黑色的位置。
Edit: So right now, this is how I am currently changing the button text color.编辑:所以现在,这就是我当前更改按钮文本颜色的方式。 Just by adding this code into my own SCSS file.
只需将此代码添加到我自己的 SCSS 文件中即可。 But it feels too hacky for me, I want to modify the Bootstrap variables.
但是对我来说感觉太hacky了,我想修改Bootstrap变量。
.btn-primary {
color: $text;
&:hover {
color: $text;
}
}
use this type使用这种类型
:root {--button-color: black; --button-background-color: silver;}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.