I need to change the style for a disabled input element in CSS.
<input type="text" class="details-dialog" disabled="disabled" />
How I can do this for Internet Explorer?
I need to change the style for a disabled input element in CSS.
<input type="text" class="details-dialog" disabled="disabled" />
How I can do this for Internet Explorer?
It seems nobody found a solution for this. I don't have one based on only css neither but by using this JavaScript trick I usually can handle disabled input fields.
Remember that disabled fields always follow the style that they got before becoming disabled. So the trick would be 1- Enabling them 2-Change the class 3- Disable them again. Since this happens very fast user cannot understand what happened.
A simple JavaScript code would be something like:
You could use the following style with opacity
or a specific CSS class
You can't for Internet Explorer.
See this comment I wrote on a related topic:
Also, see: Changing font colour in Textboxes in IE which are disabled
The following gets you pretty close in IE8 and works in other browsers too.
In your html:
In your CSS:
In IE8, there is a slight amount of border color change on hover. Some CSS for input.disabledInput:hover could probably take care of this.
It is the solution that I found for this problem:
//If IE
inputElement.writeAttribute("unselectable", "on");
//Other browsers
inputElement.writeAttribute("disabled", "disabled");
By using this trick, you can add style sheet to your input element that works in IE and other browsers on your not-editable input box.
This works for making disabled select options act as headers. It doesnt remove the default text shadow of the :disabled option but it does remove the hover effect. In IE you wont get the font color but at least the text-shadow is gone. Here is the html and css:
Here:https://jsfiddle.net/7vb3h0q4/2/