Bootstrap 5:当我点击我的按钮,颜色改变

yfwxisqw  于 2023-11-15  发布在  Bootstrap
关注(0)|答案(2)|浏览(266)

我使用引导按钮,然后我改变了按钮的颜色。但当我点击按钮,它变成蓝色,即使我写.btn-primary:active

HTML:

<button type="button" class="btn btn-primary">My Button</button>

字符串

CSS:

.btn-primary {
  background-color: #ffa500;
  border: 1px solid #e39400;
}

.btn-primary:hover {
  background-color: #e39400;
  border: 1px solid #e39400;
}

.btn-primary:active {
  background-color: #e39400;
  border: 1px solid #e39400;
}

g6ll5ycj

g6ll5ycj1#

如果你想覆盖Bootstrap的默认值,你可以将.btn-primary:active更改为:

.btn-primary:active {
    background-color: #e39400 !important;
    border: 1px solid #e39400;
}

字符串

w8rqjzmb

w8rqjzmb2#

使用!imporant,它应该工作

.btn-primary {
  background-color: #ffa500;
  border: 1px solid #e39400;
}

.btn-primary:hover {
  background-color: #e39400;
  border: 1px solid #e39400;
}

.btn-primary:active {
  background-color: #e39400 !important;
  border: 1px solid #e39400 !important;
}

字符串

相关问题