img:hover{
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
filter: grayscale(100%);
}
This CSS code snippet will convert the image from color to grayscale upon hovering. However, I am looking to achieve this effect with a smooth animation using only CSS, without resorting to jQuery.
So, what would be the best way to apply an animation effect while hovering over the image?
Update
I attempted to use the following CSS properties for grayscale effect but encountered issues in Firefox and lack of grayscaling on IE11:
filter: url("data:image/svg+xml;utf8,<svg%20xmlns='http://www.w3.org/2000/svg'><filter%20id='grayscale'><feColorMatrix%20type='matrix'%20values='0.3333%200.3333%200.3333%200%200%200.3333%200.3333%200.3333%200%200%200.3333%200.3333%200.3333%200%200%200%200%200%201%200'/></filter></svg>#grayscale"); /* Firefox 3.5+ */
filter: gray; /* IE6-9 */
-webkit-filter: grayscale(1); /* Google Chrome, Safari 6+ & Opera 15+ */
filter: grayscale(100%);
transition : filter 500ms linear;
-webkit-transition: -webkit-filter 500ms linear;
-moz-transition: -moz-filter 500ms linear;