如何在HTML / CSS中编辑按钮的活动颜色

问题描述 投票:0回答:2

我有以下代码:

<button type="button" class="btn btn-success" onclick="validateForm()">Book appointment</button><br><br>
<p id="submitted" style="background:black"><p>

enter image description hereenter image description here

黑色为按钮,绿色为活动按钮。如何更改此按钮的活动颜色?我已经尝试过多种方法,例如:

.btn.btn-success:active{
background: #933A16;
}

btn.btn-success:active{
    color #933A16;
    }

.btn:active{
  color: #933A16;
}

没有任何作用。它一直显示为绿色。我不在CSS文件上的其他任何地方都保持绿色。

html css button bootstrap-4
2个回答
0
投票

[首先,我认为您想使用background-colorbackground,我看到您在第一个示例中使用了background,但在接下来的两个示例中使用了color。您也可以尝试在分号之前添加!important语句,以覆盖引导程序的设置。


0
投票

类似于Burela所说的-添加'!important'将覆盖Bootstrap的默认设置,因此,如果最后将!important设置为您想要的背景色(而不只是背景色),那将是用过的。这是一门新课。另外,字体使用“颜色”,而不是实际的按钮。

© www.soinside.com 2019 - 2024. All rights reserved.