Skip to content

Instantly share code, notes, and snippets.

@papucho
Created April 18, 2013 20:59
Show Gist options
  • Save papucho/5416172 to your computer and use it in GitHub Desktop.
Save papucho/5416172 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