【发布时间】:2017-11-28 11:52:02
【问题描述】:
我正在自定义 Bootstrap4,但我很难理解为什么事情没有按预期工作。
导入原始 _variables.scss 并更改 $font-size-base 应该可以工作,否则我们需要在 14 个变量中更改它(例如 $h1-font-size: $font-size-base * 2.5)。以后当我更新我的“node_modules > bootstrap”时,我不必再次检查引导团队是否在任何新变量中引用了 $font-size-base。
我创建了新的_custom-variable.scss 并在其中导入了变量:
@import '../node_modules/bootstrap/scss/variables';
并将$font-size-base: 1rem 更改为$font-size-base: 0.875rem;
当我看到为 body 编译的 css 时,这工作正常:
// ../node_modules/bootstrap/scss/_reboot.scss
body {
...
font-size: $font-size-base;
...
}
// compiled css
body {
...
font-size: 0.875rem;
...
}
但问题来了,它不适用于标题标签:
// In my _custom-variable.scss, when I change $font-size-base from 1rem to 0.875
// then I expect the values changed to:
h1 { font-size: 2.1875rem }
h2 { font-size: 1.75rem }
...
h6 { font-size: .875rem }
// but nothing gets changed
h1 { font-size: 2.5rem }
h2 { font-size: 2rem }
...
h6 { font-size: 1rem }
我不确定,但我觉得这是由于这里的计算:
//../node_modules/bootstrap/scss/_variables.scss
$h1-font-size: $font-size-base * 2.5 !default;
$h2-font-size: $font-size-base * 2 !default;
...
$h6-font-size: $font-size-base !default;
【问题讨论】:
-
在你的例子中,它的工作原理是显示字体粗细而不是字体大小基数
-
@ztadic91 感谢您告诉我,这只是我的问题中的错字,我已更改。
标签: twitter-bootstrap css sass bootstrap-4