Bootstrap Sass : add color to map to work with all components (bg, text, border…)

huangapple go评论85阅读模式
英文:

Bootstrap Sass : add color to map to work with all components (bg, text, border...)

问题

我有一个关于在Bootstrap和Sass中添加新颜色到主题映射的问题。

我做错了什么?

谢谢

我尝试在我的Symfony 6.2应用程序中向Bootstrap框架(v5.2)的主题颜色中添加一个颜色。

它对按钮(.btn-mycolor)有效,但对背景和文本(.bg-mycolor,.text-mycolor)无效。

app.scss:

  1. @import "~bootstrap/scss/bootstrap";
  2. @import "custom";
  3. @import "~bootstrap/scss/bootstrap";

custom.scss:

  1. $custom-theme-colors: (
  2. "mycolor": #006A4E
  3. );
  4. $theme-colors: map-merge($theme-colors, $custom-theme-colors);
  5. $theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value");
  6. $utilities-colors: $theme-colors-rgb;
  7. $utilities-text: $utilities-colors;
  8. $utilities-text-colors: map-loop($utilities-text, rgba-css-var, "$key", "text");
  9. $utilities-bg: $utilities-colors;
  10. $utilities-bg-colors: map-loop($utilities-bg, rgba-css-var, "$key", "bg");
  11. $utilities-border: $utilities-colors;
  12. $utilities-border-colors: map-loop($utilities-border, rgba-css-var, "$key", "border");

请注意,代码部分没有翻译。

英文:

I have a problem with Bootstrap and Sass to add new colors to to theme map.

What I'm doing wrong ?

Thanks

I'm trying to add a color to theme-color of bootstrap framework (v5.2) in my Symfony 6.2 app.

It's working with buttons (.btn-mycolor) but doesn't work with background, text (.bg-mycolor, .text-mycolor)....

app.scss :

  1. @import "~bootstrap/scss/bootstrap";
  2. @import "custom";
  3. @import "~bootstrap/scss/bootstrap";

custom.scss:

  1. $custom-theme-colors: (
  2. "mycolor": #006A4E
  3. );
  4. $theme-colors: map-merge($theme-colors, $custom-theme-colors);
  5. $theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value");
  6. $utilities-colors: $theme-colors-rgb;
  7. $utilities-text: $utilities-colors;
  8. $utilities-text-colors: map-loop($utilities-text, rgba-css-var, "$key", "text");
  9. $utilities-bg: $utilities-colors;
  10. $utilities-bg-colors: map-loop($utilities-bg, rgba-css-var, "$key", "bg");
  11. $utilities-border: $utilities-colors;
  12. $utilities-border-colors: map-loop($utilities-border, rgba-css-var, "$key", "border");

答案1

得分: 1

app.scss :

  1. @import "~bootstrap/scss/functions";
  2. @import "~bootstrap/scss/variables";
  3. @import "custom";
  4. @import "~bootstrap/scss/bootstrap";
英文:

Problem resolves !

app.scss :

  1. @import "~bootstrap/scss/functions";
  2. @import "~bootstrap/scss/variables";
  3. @import "custom";
  4. @import "~bootstrap/scss/bootstrap";

huangapple
  • 本文由 发表于 2023年3月9日 22:47:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/75686183.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定