How do I desaturate and saturate an image using CSS?
Since this question is about saturation, the saturate()
filter may be a better fit. This also allows for super-saturated colors (values above 100%):
img {
filter: saturate(0%);
}
img:hover {
filter: saturate(300%);
}
https://jsfiddle.net/t1jeh8aL/
You just have to reverse the grayscale for each browser prefix CSS property:
img:hover {
filter: none;
-webkit-filter: grayscale(0%);
-moz-filter: grayscale(0%);
-ms-filter: grayscale(0%);
-o-filter: grayscale(0%);
cursor: pointer;
}
http://jsfiddle.net/7mNEC/1/
Its cooler if you add a transition like this:
img {
filter: none;
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
cursor: pointer;
transition: all 300ms ease;
}
img:hover {
filter: none;
-webkit-filter: grayscale(0%);
-moz-filter: grayscale(0%);
-ms-filter: grayscale(0%);
-o-filter: grayscale(0%);
}