Created
August 26, 2012 12:17
-
-
Save karlhorky/3478370 to your computer and use it in GitHub Desktop.
Cross-Browser CSS Grayscale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
img.grayscale.disabled { | |
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><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"); | |
-webkit-filter: grayscale(0%); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
img.grayscale { | |
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+, Firefox on Android */ | |
filter: gray; /* IE6-9 */ | |
-webkit-filter: grayscale(100%); /* Chrome 19+, Safari 6+, Safari 6+ iOS */ | |
} |
can anyone help me in applying 'grayscale' in safari 5.1.... i tried filter: url as well.... it dint't support...
Plz help..
Safari 5.1? What year is this?
doesnt work in ie 11
doesn't work on ie 11
Clearly does not work on IE11 by default.
To everyone saying it doesn't work on ie11. Duh. https://caniuse.com/#search=filter
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What Klaymen says would work, but it is not a good practice.
You shouldn't force IE10 to render like IE9. I suggest that you check out this tutorial that solves grayscale images even on IE10 and IE11.
I suggest that you use this solution that is cross-browser friendly way making images grayscale even on Internet Explorer. Here is the demo - http://www.majas-lapu-izstrade.lv/cross-browser-grayscale-ie11