【发布时间】:2018-12-01 20:26:31
【问题描述】:
我正在使用Bootstrap 4 和 Sass (scss) 创建一个网站。我遇到的问题是我的导航中的链接是灰色的,而不是我想要的蓝色。
我能找到的关于这个主题的每个主题都建议覆盖导航项的样式。在我看来,这会在以后的开发过程中咬你一口。所以覆盖变量而不是样式是我的偏好,但不知何故它对我来说不能正常工作。
我已经通过推荐的方式覆盖了引导样式:
- 创建带有颜色覆盖的 scss 文件
- 通过
$theme-colors函数更改样式 - 在
bootstrap.scss文件之前导入主题文件。
我的_theme.scss如下:
@import "~bootstrap/scss/functions";
@import "~bootstrap/scss/variables";
$blue: #0053CB;
$blue-700: #0F2C92;
$white: #FFFFFF;
$green: #39CA71;
$red: #F1453D;
$orange: #fd7e14;
$yellow: #FDC02F;
$gray-100: rgba(0,0,0,.03);
$theme-colors: (
primary: $blue,
secondary: $white,
light: $white,
dark: $blue-700,
success: $green,
warning: $orange,
danger: $red,
);
// Import bootstrap as last so that the variables will be overridden
@import '~bootstrap/scss/bootstrap';
$link-hover-color(用于导航链接)的引导代码如下:
$link-color: theme-color("primary") !default;
$link-hover-color: darken($link-color, 15%) !default;
问题是我定义的主题颜色在我的 html 中使用 bg-primary 时正确使用,但悬停和链接颜色不是我预期的蓝色,它们是灰色的,就像默认值一样。我的设置中有什么遗漏还是我做错了什么?
【问题讨论】:
标签: twitter-bootstrap sass bootstrap-4 themes