Skip to content

Instantly share code, notes, and snippets.

@mamged
Created March 16, 2016 10:05
Show Gist options
  • Save mamged/8d312cee8cec1e62d081 to your computer and use it in GitHub Desktop.
Save mamged/8d312cee8cec1e62d081 to your computer and use it in GitHub Desktop.
css filter with IE fallback works perfectly on IE 6+
.gray-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+, Firefox on Android */
filter: grayscale(100%); /* moz fix */
filter: gray; /* IE6-9 */
-webkit-filter: grayscale(100%); /* Chrome 19+, Safari 6+, Safari 6+ iOS */
opacity: 0.7;
-webkit-transition: all 0.5s;
transition: all 0.5s;
}
.gray-hover:hover {
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");
filter: none;
-webkit-filter: none;
opacity: 1;
}
@blubbll
Copy link

blubbll commented Oct 20, 2018

nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment