Reputation: 1372
When I'm hovering the image I would like it to turn black. The image is gray by default.
img:hover {
filter: grayscale(100%) brightness(1.6) saturate(2) contrast(150);
}
<img src="https://i.sstatic.net/wpQiz.png">
Upvotes: 0
Views: 103
Reputation: 273649
Use the invert filter and you will get closer:
img:hover {
filter: invert(1);
}
<img src="https://i.sstatic.net/wpQiz.png" >
Or simply brightness(0)
img:hover {
filter: brightness(0);
}
<img src="https://i.sstatic.net/wpQiz.png" >
Upvotes: 3
Reputation: 78726
Why not think the other way around, use a black image and change the visual with opacity
levels?
img {
width: 100px;
height: auto;
opacity: .5;
transition: opacity .25s;
}
img:hover {
opacity: 1;
}
<img src="https://i.sstatic.net/Eo3De.png">
Upvotes: 2
Reputation:
Could not the following be done? (you would need 2 separate images though, one gray and one colored black)
<img src='../img/badge/graydot.png' onmouseover="this.src='../img/badge/blackdot-hover.png';" onmouseout="this.src='../img/badge/graydot.png';" />
Upvotes: 1