css - 在 Bootstrap 中更改原色不起作用?
问题描述
我正在创建一个反应应用程序,并且我已经安装了 Bootstrap React。
我想改变原色,也就是蓝色,所以我去了bootstrap/scss/variable.scss
然后我更改了以下内容:
$blue: #445448 !default;
因此,改变所有$primary: $blue !default;
但是,原色给我蓝色?
我npm start
再次停止了我的服务器,但没有任何效果。
解决方案
您应该添加一个名为custom.scss
example 的文件并添加以下内容:
// override Bootstrap variables here
// override the primary Bootstrap color
$primary: #12a2f9;
@import "~bootstrap/scss/bootstrap"
请注意,您应该在实际引导导入之前添加变量覆盖。
main.scss
并在or 中的 bootstrap 导入之前或之后App.js
导入此文件index.js
编辑:假设这是您的项目根结构,请执行以下操作:
成分/ 应用程序.js 主文件 自定义.scss index.js 应用程序.test.js
您将在App.js
示例中编写此代码:
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
// This import contains the custom variables written above
import "./custom.scss";
// This import contains the actual scss code
import "./main.scss";
ReactDOM.render(
<App />,
document.getElementById("root")
);
推荐阅读
- r - plot.dendrogram 中的挂起参数不起作用(说[“挂起”不是图形参数])
- swift - 全局变量未使用所有视图共享的相同实例化
- javascript - Promise.all 不适用于所有项目,除非我更改订单?
- mysql - 仅当数据库中尚不存在同名表时,如何将表创建为另一个表?
- ios - SwiftUI:如何在容器视图中垂直和水平居中并在其下放置一些东西
- c++ - C++结构成员在接收原始地址作为成员函数参数后指向另一个内存位置
- python - 如何在 Python3 中使用自定义的下溢/溢出箱绘制构面直方图?
- powershell - 如何测试在 Transact SQL 中设置的环境变量?
- splunk - 从 linux cli 更改 splunk 管理员密码
- firebase - Unity 编辑器中的 Firebase 初始化失败