my question says it all. I'm interested in the text color and the background color that disabled text-boxes in HTML use ( the entire CSS a disabled text-box use is also welcomed ). I need this so I would match the color settings of some readonly text-boxes with the color of disabled text-boxes in my html page ( don't want them to stick out ).
P.S. I need readonly text-boxes so I can capture events with them.
The background color for a disabled input in chrome is rgb(235,235,228) if that helps .. In firefox the disabled input background-color is F0F0F0.
Approach: With adding basic CSS property we are able to change the font-color of a disabled input. The disabled input element is unusable and un-clickable. This is a boolean attribute. Here using the color property of input we can change the font-color of this disabled input element.
HTML used to recognize 16 color names ("black", "white", "gray", "silver", "maroon", "red", "purple", "fushsia", "green", "lime", "olive", "yellow", "navy", "blue", "teal", and "aqua"), but new browsers can recognize 147 CSS3 color names.
To add background color in HTML, use the CSS background-color property. Set it to the color name or code you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a table, heading, div, or span tag.
The background color is rgb(235, 235, 228);
or #EBEBE4
in hex.
At least that's the value in chrome (checked with the debugger tools). This value could be different in other browser
I implemented the following to make any read-only textbox or textarea (useful in my case) appear disabled when it was readonly.
<style>
input:read-only,
textarea:read-only,
[contenteditable]:read-only {
cursor: not-allowed;
background-color: #EBEBE4 !important;
color: #C6C6C6;
}
</style>
Or this:
<style>
input:read-only,
textarea:read-only,
[contenteditable]:read-only {
pointer-events: none;
background-color: #EBEBE4 !important;
color: #C6C6C6;
}
</style>
Hopefully this helps someone!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With