I am using the following CSS to get a grayscale effect on hover. The issue in Firefox is that it blurs the image slightly and also shifts it to the right by 1–2 pixels. I am not sure why this is happening.
Is this an inherent issue? How can I solve it?
.zd-stack img:hover {
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale");
/* Firefox 10+ */
filter: gray; /* IE6-9 */
-webkit-filter: grayscale(100%); /* Chrome 19+ & Safari 6+ */
-webkit-transition: all .6s ease; /* Fade to color for Chrome and Safari */
-webkit-backface-visibility: hidden; /* Fix for transition flickering */;
}
I want to use CSS, but don't know how to correct this minor issue!
The issue between Firefox and SVG grayscale seems to be fixed now.
See the fiddle with your code sample: https://jsfiddle.net/tzi/rjotsz0p/
Firefox supports grayscale()
filter from version 35 (January 2015), so you can now have a much better version of this code:
.zd-stack img {
transition: filter .6s ease; /* Standard (all but IE10+) */
}
.zd-stack img:hover {
filter: gray; /* For IE6-12 */
filter: grayscale(100%); /* Standard (only FF35+ & IE13+) */
-webkit-filter: grayscale(100%); /* For Chrome, Safari & Opera */
}
See the fiddle with this new code: https://jsfiddle.net/tzi/x6xcx68g/
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