简体   繁体   English

更改 Bootstrap btn-primary class 的默认颜色

[英]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.

相关问题 如何在 React bootstrap Styled Component 中覆盖 -btn-primary 类 - How to override -btn-primary class in React bootstrap Styled Component Bootstrap btn-primary出现在悬停上 - Bootstrap btn-primary appear on hover 如何从我的 custom.css 文件中应用 btn btn-primary bootstrap class? - how to apply btn btn-primary bootstrap class from my custom.css file? Bootstrap btn-primary按钮意外的悬停颜色和效果。 我该如何改写? - Bootstrap btn-primary button unintended hover color and effect. How do I override this? 如何将btn btn-primary类添加到锚标记? - How to add btn btn-primary class to anchor tag? Twitter Bootstrap“ Dropdown Toggle”是否位于“ btn btn-block btn-lg btn-primary”上? - Twitter Bootstrap “Dropdown Toggle” on “btn btn-block btn-lg btn-primary”? Twitter Bootstrap btn-primary大小IE8 - Twitter Bootstrap btn-primary Size IE8 将bootstrap单选按钮分组为不同列中的btn-primary按钮 - Grouped bootstrap radio buttons as btn-primary buttons in different columns 更改引导程序选择的边框颜色(btn类) - Change border color of bootstrap select (btn class) 如何在LESS中定义具有class =“ btn btn-primary”类的元素 - How can I define in LESS an element that has a class of class=“btn btn-primary”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM