首页 > 解决方案 > 在 mixin 中修改 Bootstrap 变量

问题描述

使用 Bootstrap 4,我正在尝试更改brand-primarymixin 中的值:

// variables
$theme-colors: (
  "main": #9fa28b,
  "another-section": #ec008c,
  "yet-another-section": #00b0d8
);

// main scss
@mixin theme($color){
    $theme-colors: (
        "brand-primary": $color
    );
}

body {
    @include theme(theme-color($key: "main"));

    &.another-section {
        @include theme(theme-color($key: "another-section"));
    }

    &.yet-another-section {
        @include theme(theme-color($key: "yet-another-section"));
    }
}

这编译没有错误,但没有类another-sectionyet-another-section在编译的 css 中。

有没有办法brand-primary在 mixin(或任何变量)中覆盖?

标签: csssassbootstrap-4scss-mixins

解决方案


如果我理解你是正确的,你想改变颜色。您所要做的就是覆盖原色检查此链接如何更改引导程序原色?


推荐阅读