【问题标题】:How can I use extended bootstrap 5 colors on Angular?如何在 Angular 上使用扩展的引导程序 5 种颜色?
【发布时间】:2021-05-23 17:27:52
【问题描述】:

我在 Angular 12 项目(带有 scss)上使用 Bootstrap 5,但我找不到使用新扩展 bootstrap 5 调色板(如 indigo-300 或 pink-200 等)的方法。 '不知道我是否需要以某种方式导入它们,或者如何在 Angular 上做到这一点。

【问题讨论】:

    标签: css angular sass colors bootstrap-5


    【解决方案1】:

    询问和检查后,我得出两个结论:

    如果您只想在一个类中使用这些颜色,请使用变量

    .custom
    {
        color:$indigo-300;
    }
    

    但如果你想用作原色,例如你的 styles.scss 应该是这样的

    //see it's necesary import both scss/functions and scss/variables
    
    @import "../node_modules/bootstrap/scss/functions";
    @import "../node_modules/bootstrap/scss/variables";
    
    $primary:       $pink-600;
    $secondary:     $yellow-300;
    $success:       $green;
    $info:          $cyan;
    $warning:       $yellow;
    $danger:        $red;
    $light:         $gray-100;
    $dark:          $gray-900;
    
    //futhermore it's necesary override the $theme-colors
    
    $theme-colors: (
      "primary":    $primary,
      "secondary":  $secondary,
      "success":    $success,
      "info":       $info,
      "warning":    $warning,
      "danger":     $danger,
      "light":      $light,
      "dark":       $dark
    );
    
    
    @import '../node_modules/bootstrap/scss/bootstrap.scss';
    

    【讨论】:

    • 非常感谢,原来是我导入bootstrap的函数和变量的方式不对
    猜你喜欢
    • 2021-08-02
    • 1970-01-01
    • 1970-01-01
    • 2021-12-27
    • 2022-08-09
    • 2018-06-23
    • 2018-04-10
    • 2016-12-28
    • 2021-09-05
    相关资源
    最近更新 更多