3

How to disable button color change when mouse hover over button or user push the button?

I'm using bootstrap:

<link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/bootswatch/3.2.0/sandstone/bootstrap.min.css'>

And here is some part of code that use button:

<form id="idForm1" method="post" action="/web_crawler">
    <h4> Web crawler requests: </h4><br>
    <textarea id="id_text_requests" name="text" rows="5" cols="20" style="resize:none">{{text_requests}}</textarea><br>
    <input id="form1_send_button" type="button" class="btn" value="Run web crawler">
    <br>
</form>

UPDATE:

Base on answers and suggestions, here is (not perfect) solution with css, but I hardcoded color(maybe it can be done in some automated way?) and also after button is in clicked state some dotted frame appears, how to remove it?

Here example:

.btn:hover {
    background:#325d88;
    }
.btn:active:focus { 
    color: #FFFFFF;
    }
.btn:focus { 
    background: #325d88;
    color: #FFFFFF;
    }

enter image description here

Update 2:

Looks like it was firefox related problem:

This can fix it:

.btn:focus { 
    background: #325d88;
    color: #FFFFFF;
    outline:none;
    }
mrgloom
  • 20,061
  • 36
  • 171
  • 301
  • What have you tried to do so far? – Phiter Feb 09 '18 at 10:42
  • I think it's best if you use a custom button because bootstrap does all that styling every time. – Phiter Feb 09 '18 at 10:43
  • Possible duplicate of [What is a Bootstrap disabled button hover class name?](https://stackoverflow.com/questions/43343575/what-is-a-bootstrap-disabled-button-hover-class-name) – Ele Feb 09 '18 at 10:45
  • **You can do it with css ** [Click here to see the solution](https://stackoverflow.com/questions/14750078/style-disabled-button-with-css) – Rizwan Feb 09 '18 at 10:47

2 Answers2

2

Create a style of disabled button in every states: :disabled, :hover, :active

.btn:disabled,
.btn:disabled:hover,
.btn:disabled:active,
.btn:disabled:hover:active {
    // Your disabled styles
}

Live Demo: https://jsfiddle.net/565ang1z/

ram12393
  • 1,284
  • 3
  • 14
  • 29
Bigdragon
  • 352
  • 1
  • 4
  • 16
1

You can use this css

#idForm1    .btn:focus,
#idForm1    .btn:active:focus,
#idForm1    .btn.active:focus,
#idForm1    .btn.focus,
#idForm1    .btn:active.focus,
#idForm1    .btn.active.focus {
  outline: none;
  outline-offset: 0;
}
#idForm1    .btn:hover,
#idForm1    .btn:focus,
#idForm1    .btn.focus {
  color: #333;
  text-decoration: none;
}
#idForm1    .btn:active,
#idForm1    .btn.active {
  background-image: none;
  outline: 0;
  -webkit-box-shadow: none;
  box-shadow: none;
}
Athul Nath
  • 2,536
  • 1
  • 15
  • 27