Skip to content

Instantly share code, notes, and snippets.

@neilwong2012
Forked from papucho/file.html
Created February 27, 2020 08:50
Show Gist options
  • Save neilwong2012/f6a541cbec7859d485a093870b736717 to your computer and use it in GitHub Desktop.
Save neilwong2012/f6a541cbec7859d485a093870b736717 to your computer and use it in GitHub Desktop.
Grayscale filter using SVG+CSS
<img src="http://lorempixel.com/400/200/sports/" alt="" class="fader">
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
img.fader {
filter: url(filter.svg#grayscale); /* Firefox 3.5+ */
filter: gray; /* IE6-9 */
-webkit-filter: grayscale(1); /* Google Chrome & Safari 6+ */
-webkit-transition: all 2s;
}
img:hover {
filter: none;
-webkit-filter: grayscale(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment