Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change color of Bootstrap disabled button?

Tags:

html

css

button

I am using a bootstrap button on a page of my website and I want to change the color of a disabled button. A button that is "grayed out" and you cannot click. Is there a way I can change the color of this using CSS? Any class for this?

Thank you very much!

like image 821
Oliver Beck Avatar asked Mar 05 '16 18:03

Oliver Beck


People also ask

Can you change Bootstrap button color?

Bootstrap Button Colors You can by using the . btn class in your HTML and the class selector in your CSS.

What is the color of disabled button?

Gray is often used to communicate a low priority button (e.g., cancel buttons). When they see a gray button, they won't know for sure if it's disabled unless they click it.

How do I make a button disabled in Bootstrap?

Use the . disabled class in Bootstrap to disable a button.

How do I change the toggle button color in Bootstrap 5?

navbar-dark: This class is used to set the color of the navigation bar content to light. It will change the toggler icon to have white lines.


2 Answers

In case your button look like this:

<button class="btn btn-primary" disabled>Button</button>

the next CSS code will change its color (when disabled only):

.btn.btn-primary[disabled] {
    background-color: #00ff00;
}

or

.btn.btn-primary:disabled{
    background-color: #00ff00;
}
like image 159
Jumpa Avatar answered Nov 04 '22 01:11

Jumpa


If I understand your question correctly; you need to use :disabled. Here is a working code:

#work {
  width: 200px;
  height: 50px;
  color: black;
}

#work:disabled{
  background-color: red;
}
<button id="work"disabled="true" type="submit">Button </button>
like image 44
Graphicoding Avatar answered Nov 04 '22 01:11

Graphicoding