[英]bootstrap primary color override doesn't work after button click
I am trying to override bootstrap 5's primary color using scss.我正在尝试使用 scss 覆盖引导程序 5 的原色。 This works fine until after I click a button that opens an external link.
在我单击打开外部链接的按钮之前,这可以正常工作。
Here is my scss file:这是我的scss文件:
$primary: #ae217aff;
@import "../node_modules/bootstrap/scss/bootstrap.scss";
Here is my stylesheet import in index.html:这是我在 index.html 中导入的样式表:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor"
crossorigin="anonymous"
/>
<link rel="stylesheet" href="./html/index.css" />
<link rel="stylesheet" href="./html/animations.css" />
<title>title</title>
<script defer src="../render.js"></script>
</head>
<body>
<form>
<div class="input-group">
<input
type="url"
class="form-control"
placeholder=""
required
/>
<div class="input-group-append">
<button
class="btn btn-outline-primary"
type="button"
id="testBtn"
>
Get Spreadsheet Template
</button>
</div>
</div>
</form>
<script src="../render.js"></script>
<script
src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"
crossorigin="anonymous"
></script>
<script
src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"
></script>
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin="anonymous"
></script>
</body>
</html>
And here is the javascript to open the link:这里是 javascript 打开链接:
templateBtn = document.getElementById("testBtn");
templateBtn.addEventListener("click", (event) => {
event.stopImmediatePropagation();
window.open(
"",
"_blank"
);
My index.css file is the result of running the command "sass index.scss index.css" (aka compiling to a css file).我的 index.ZC7A628CBA22E28EB17B5F5C6AE2A266AZ 文件是运行命令“sass index.scss index.css”(又名编译为 ZC7A628CBA22E28EB17B5F5C6AE2A266AZ 文件)的结果。 Here is a before/after photo of the button click:
这是按钮单击之前/之后的照片:
You should get rid of the cdn version, and just use one scss-compiled version of bootstrap.您应该摆脱 cdn 版本,而只使用一个 scss 编译版本的引导程序。 Take advantage by changing variables of bootstrap AND using their variables in your classes.
通过更改引导程序的变量并在您的类中使用它们的变量来利用它们。
From their docs , I also use this approach:从他们的文档中,我也使用这种方法:
// my-bootstrap-and-styles.scss
// your overrides
$primary : #FEBC35;
// include bootstrap.scss
@import "../node_modules/bootstrap/scss/bootstrap";
// Then add your additional custom code here
.my-primary-div {
background: $primary;
border: 1px solid black;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.