I have been attempting to convert my images to grayscale using CSS, but have encountered an issue with Firefox where it requires the use of SVG. However, utilizing SVG causes problems with other functionalities such as opacity and transitions.
Is there a similar solution using jQuery that is compatible with all browsers?
Below is the CSS code I am currently using:
#myimage img{
width: 100%;
-webkit-filter: grayscale(100%) contrast(60%) opacity(.3);
-moz-filter: grayscale(100%) contrast(60%) opacity(.3);
-ms-filter: grayscale(100%) contrast(60%) opacity(.3);
-o-filter: grayscale(100%) contrast(60%) opacity(.3);
filter: grayscale(100%) contrast(60%) opacity(.3);
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\' filterRes=\'800\'><feColorMatrix type=\'matrix\' values=\'1 0 0 0 0, 0 1 0 0 0, 0 0 1 0 0, 0 0 0 1 0\'/></filter></svg>#grayscale");
filter: gray; /* IE 6-9 */
filter:alpha(opacity=6);
-moz-opacity: 0.6;
o-transition: .7s;
-ms-transition: .7s;
-moz-transition: .7s;
-webkit-transition: .7s;
transition: .7s;
}
#myimage img:hover{
width: 100%;
-webkit-filter: none;
-moz-filter: none;
filter: none;
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\' filterRes=\'800\'><feColorMatrix type=\'matrix\' values=\'1 0 0 0 0, 0 1 0 0 0, 0 0 1 0 0, 0 0 0 1 0\'/></filter></svg>#grayscale");
opacity: (.5);
o-transition: .7s;
-ms-transition: .7s;
-moz-transition: .7s;
-webkit-transition: .7s;
transition: .7s;
}
If anyone has experience in solving this issue, I would greatly appreciate your assistance.