我无法弄清如何更改Bootstrap 4切换开关的“checked”背景颜色。 它使用额外的库来切换深色和浅色模式-在这里 on github - 但那个是可行的。 我想做的就是更改默认情况下为蓝色的活动复选框的背景颜色。 它是否从Bootstrap CSS默认为蓝色? 这个答案Change Bootstrap 4 checkbox background color对我不起作用; 它只更改未选中的颜色,但我无法从中找到如何更改“checked”颜色的grep信息。
我的代码:
.custom-control-input {
background-color: red;
}
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="darkSwitch" />
<label class="custom-control-label" for="darkSwitch">Dark Mode</label>
</div>
box-shadow
保留,你可以轻松地在我的代码中删除那些box-shadow
,但我认为这不是一个好主意,因为它看起来有点丑。 - Umutambyi Gadbox-shadow
,但在我的Chrome浏览器中却有效。 - Umutambyi Gad