In addition to Firefox, it also happens on IE11. Because it is a button, the mouse events (mouseover, mouseleave, etc.) are all linked to the button itself, and not to its child elements. With that, a :hover
applied directly to a child element of the button
will not answer. Whether it is a bug or not (there are signs for this as quoted by Netinho’s reply) I can not say, but it is the way that these browsers treat this case.
But I find it hard to be a bug. See that the link in Bugzilla pointed out in Netinho’s response is 6 years ago. Since then Firefox has suffered many updates (as well as IE). If it was really a bug, I think it would have been fixed by now.
But one way around it is by putting the :hover
on the button pointing to the child element:
button {
padding: 10px;
cursor: pointer;
}
.images {
opacity: 0.25;
}
button:hover .images{
opacity: 1;
}
<button type="button">
<img class="images" src="https://placecage.com/100/100">
</button>
Note that up to the property cursor: pointer;
had to be applied to
button
and not to the image. Otherwise, it would not answer either.
Nice uncle, it seems that’s right, and I still preserve the opacity of the button intact, only the image that changes the opacity. Vlw
– hugocsl