I would like to change the opacity of the image only when it is in the off state, as I do for the input buttonbelow:
button
input[type="button"]:disabled { border: 1px solid #AAA; border-radius: 4px; opacity:0.5; } img:disabled { opacity:0.5; }
Normal button: <input type="button" value="Close" /><br> Disabled button: <input type="button" value="Cancel" disabled="true"/> <br><br> Normal: <img src="http://i.stack.imgur.com/AkfB4.png" /><br> Disabled: <img src="http://i.stack.imgur.com/AkfB4.png" style="opacity:0.5" disbled />
But it does not work for images if I add :disabledin css. Please help me with this.
:disabled
As indicated by W3C :
An element is called virtually disabled if it falls into one of the following categories:Button Elementsinput elements that are disabledSelect items that are disabled.disabled textarea elementsoptgroup elements that have a disabled attributeOption items that are disabledfieldset,.. , : disabled.
An element is called virtually disabled if it falls into one of the following categories:
.. , : disabled.
, :disabled . .
input type image.
input
image
disabled:
disabled
input[type=image]:disabled { opacity:0.5; }
<input type="image" src="https://placeholdit.imgix.net/~text?txtsize=56&txt=Example&w=300&h=150&txttrack=0" border="0" disabled />
, , onclick="return false;" input.
onclick="return false;"
@DevonBernard, , CSS, .
img.disabled { opacity:0.5; }
<img src="https://placeholdit.imgix.net/~text?txtsize=56&txt=Example&w=300&h=150&txttrack=0" alt="Image" class="disabled">
disabled ( ), :
img[disabled] { opacity:0.5; }
<img src="https://placeholdit.imgix.net/~text?txtsize=56&txt=Example&w=300&h=150&txttrack=0" alt="Image" disabled>
, disabled . ( ).
CSS3: (, ..), , img, :
, CSS. , , " " , , , , "" .
You can also use the CSS selector for the "disabled" state, which works fine in my case:
button[disabled] > img { opacity: 0.5; }
Best manuel