【发布时间】:2019-06-03 14:31:25
【问题描述】:
我想使用 Sass 变量更改引导程序中输入组件的活动颜色。
我已将我的颜色添加到地图主题颜色中。但是,似乎在某些情况下,引导程序会忽略主题颜色中设置的原色并使用默认的蓝色原色
twitter-bootstrap 4.3.1
$spanish_green: #009150';
$theme-colors: (
"primary": $spanish_green,
"secondary": $purple,
"warning": $yellow,
);
$component-active-bg: theme-color("primary");
// _variables.scss from node_modules/bootstrap/scss
//$input-focus-border-color: lighten($component-active-bg, 25%) !default;
@debug "Primary color : '#{theme-color("primary")}'."
prints... #009150
@debug "Color of component-active-bg:' #{$component-active-bg:}'."; // prints ...#009150'
@debug "Color of input-focus-border-color:' #{$input-focus-border-color:}'.";
prints ... #80bdff // the primary bootstrap default color
我希望变量 input-focus-border-color 会使用我为 $component-active-bg 设置的值,即主题颜色(“primary”)而不是默认的蓝色引导
感谢您的帮助和反馈。
【问题讨论】:
-
我只是测试你的代码:
$spanish_green: #009150; $theme-colors: ("primary": $spanish_green); $component-active-bg: theme-color("primary");和$input-focus-border-color的值#12ff95 -
我会说,这是我所期望的结果,但再次运行它仍然无法正常工作。
-
如果我重复代码(来自引导程序的 _variables.scss)
$component-active-bg: theme-color("primary"); $input-focus-border-color: lighten($component-active-bg, 25%);不明白为什么我必须重复该代码才能工作。 -
如果您不想从
$theme-colors添加/删除道具,您可以在“变量文件”中定义自己的$primary变量。 -
这是我在基于 Bootstrap github.com/cichy380/html-starter-bs4-webpack/blob/… 的项目中基于 7-1 Sass 架构的 sass 文件结构