Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable button color change when mouse hover over button

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;
    }
like image 941
mrgloom Avatar asked Dec 20 '25 07:12

mrgloom


2 Answers

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/

like image 141
Bigdragon Avatar answered Dec 21 '25 23:12

Bigdragon


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;
}
like image 29
Athul Nath Avatar answered Dec 21 '25 23:12

Athul Nath



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!