Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set CSS for disabled checkboxes?

Tags:

html

css

checkbox

I'd like change the CSS for disabled checkboxes in a grid (they are too hard to see for the users). What is a simple way to do this?

My preference in technologies used (in descending order):
CSS
JavaScript
jQuery
Other

like image 718
Even Mien Avatar asked Jul 30 '09 14:07

Even Mien


2 Answers

I'd suggest changing the colour of the background (the background-color of the form/fieldset), and see if you can come up with a better contrast. If you just want to change the colour of disabled (non-selectable?) checkboxes you can try:

input[disabled] {
...
/* CSS here */
...
}

But if they're disabled for a reason, surely they don't need to be prominently visible? The aim for their being greyed-out is, surely, to avoid confusion between active/enabled and inactive/disabled form elements?

like image 105
David Thomas Avatar answered Sep 21 '22 15:09

David Thomas


Keep the checkbox enabled, but then add onfocus=this.blur() to the checkbox so it cannot be clicked.

Or if using ASP.net (as you say in your comment) keep the checkbox set to enabled and add the following to the Page.Load event:

CheckBox1.Attributes.Add("onclick", "return false;");
like image 26
David Avatar answered Sep 18 '22 15:09

David