How to change background color of active button when i am using bootstrap?

13,454

You need to target .btn-primary:focus too. It is .btn-primary:focus that is responsible for coloring the buttons #3276b1 after click :

.btn-primary:focus,
.btn-primary:active,
.btn-primary.active {
    background-color: #111111;
    border-color: #000000;
}

then it works -> http://jsfiddle.net/y5jo73wo/

Share:
13,454
Sachin Sharma
Author by

Sachin Sharma

I Prefer to keep an air of mystery about me.

Updated on June 04, 2022

Comments

  • Sachin Sharma
    Sachin Sharma almost 2 years

    Currently i am using the following: with this the normal background color and hover state color are changed but when i click a button it becomes light blue(i.e. active state) what is it that i am missing?

    .btn-primary{
        font-family: TimeBurner;
        font-size: 15px;
        background-color: #232323;
        border-color: #222222;
    }
    .btn-primary:hover{
        background-color: #111111;
        border-color: #000000;
    }
    .btn-primary.active, .btn-primary:active{
        background-color: #111111;
    	border-color: #000000;
    }
     <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
      <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <div class="row">
      <div class="col-md-3 text-center">
          <button type="button" class="btn btn-primary" ng-click="getRatePerKGAir()">
              Rate/KG Air
          </button>
      </div>
      <div class="col-md-3 text-center">
          <button type="button" class="btn btn-primary" ng-click="getRatePerKGSurface()">
              Rate/KG Surface
          </button>
      </div>
      <div class="col-md-3 text-center">
          <button type="button" class="btn btn-primary" ng-click="getSalienceAir()">
              Salience Air
          </button>
      </div>
      <div class="col-md-3 text-center">
          <button type="button" class="btn btn-primary" ng-click="getSalienceSurface()">
              Salience Surface
          </button>
      </div>
    </div>
  • Arun
    Arun over 8 years
    can you please create fiddle link
  • Sachin Sharma
    Sachin Sharma over 8 years
    still my issue wasn't resolved....needed to add :focus as well. thanks for your time though :)