按下 Bootstrap 4 按钮改变颜色

1 html css button bootstrap-4

我更改了按钮的 bootstrap css 类,更改了按钮颜色、字体大小和字体颜色等。

但是当我按下按钮并按住鼠标时,它会改变颜色。

我将颜色设置为绿色,但是当我单击按钮并按住鼠标时,它会变成蓝色。

这是按钮的css代码

.btn-outline-primary{
  width: 220px;
  background: #A4D555; /*2cc8df*/
  border: none;
  color: white;
  font-weight:450;
}

.btn-outline-primary:hover{
  background: #A4D555;
  outline: none;
  box-shadow: none;
}

.btn-outline-primary:focus{
  background: #A4D555;
  outline: none;
  box-shadow: none;
}

.btn-outline-primary:active{
  background: #A4D555;
  outline: none;
  box-shadow: none;
}
Run Code Online (Sandbox Code Playgroud)

לבנ*_*לכה 5

您必须添加!important以防止引导程序定义覆盖

.btn-outline-primary{
  width: 220px;
  background: #A4D555!important; /*2cc8df*/
  border: none;
  color: white;
  font-weight:450;
}

.btn-outline-primary:hover{
  background: #A4D555!important;
  outline: none;
  box-shadow: none!important;
}

.btn-outline-primary:focus{
  background: #A4D555!important;
  outline: none;
  box-shadow: none !important;
}

.btn-outline-primary:active{
  background: #A4D555!important;
  outline: none;
  box-shadow: none !important;
}
Run Code Online (Sandbox Code Playgroud)
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<button type="button" class="btn btn-outline-primary">Primary</button>
Run Code Online (Sandbox Code Playgroud)


编辑您的评论:

但是当我点击并按下时仍然有一个蓝色边框/轮廓


放:

box-shadow: none!important;
Run Code Online (Sandbox Code Playgroud)