css - Bootstrap 4.1.3 $font-family-base 被忽略
问题描述
我正在尝试更改 Bootstrap 中的默认字体系列,但我的更改被忽略了。
这个问题在回购(https://github.com/twbs/bootstrap/issues/21595)上已关闭,但我仍然有问题。
> bundle info bootstrap
=> bootstrap (4.1.3)
我有bootstrap-custom.scss
:
/*!
* Bootstrap v4.1.3 (https://getbootstrap.com/)
* Copyright 2011-2018 The Bootstrap Authors
* Copyright 2011-2018 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
...
@import "bootstrap/variables";
...
_variables.scss
:
...
//== Typography
//
//## Font, line-height, and color for body text, headings, and more.
$font-family-sans-serif: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif !default;
$font-family-serif: Georgia, "Times New Roman", Times, serif !default;
//** Default monospace fonts for `<code>`, `<kbd>`, and `<pre>`.
$font-family-monospace: Menlo, Monaco, Consolas, "Courier New", monospace !default;
$font-family-base: $font-family-sans-serif !default;
...
我将它导入application.scss
到我的文件顶部:
@import "bootstrap-custom";
@import "variables";
如果我尝试这个 css,那是行不通的:
body {
font-family: $font-family-base;
}
但是,如果我更改名称并$font-family-base
在_variables.scss
正文中使用新变量,它就可以工作。
我有什么问题吗?
解决方案
这种可能性非常小,但是您是否正确检查了文件名?
从您的代码来看,自定义样式文件名似乎是bootstrap_custom.scss
,而您导入的文件名是bootstrap-custom
.
查看文件名中_(下划线)和-(破折号/连字符)的区别。
推荐阅读
- javascript - Vue.js 分页计算未按预期工作
- javascript - 反应:为每个孩子添加一个事件侦听器并将一个引用传递给父母的事件处理程序 - 效率低吗?事件冒泡可能吗?
- excel - 使用 VBA-Selenium 将表格数据提取到不同的 Excel 工作表中
- reactjs - onChange 不适用于 FromControl React Bootstrap
- php - 在codeigniter 4中找不到错误类'Codeigniter \ Model'
- vue.js - 如果作为全局配置对象导入,如何从 element-ui 获取单个组件(轮播)?
- php - PHP MySQL array_pad() 在多维数组上显示 html 表中的值
- github - 尝试托管自定义字体
- kdb - KDB/q count 行数按列的值分组
- algorithm - 以最小的损失量和最相似的空间打包矩形的算法(用于多用户视频室)