Created
May 23, 2015 10:36
-
-
Save SiGaCode/998ce9781fb5578d8939 to your computer and use it in GitHub Desktop.
Display images in greyscale and fade in color on hover - with SVG and CSS. For portfolios, for example.
Credits: http://pandjarov.com/make-your-gallery-fade-to-colour-with-only-svg-and-css/
This file contains hidden or 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
| /*You can modify the “darkness” of the image by playing with the SVG used.*/ | |
| /*Hint: Use a specific selector, else it will apply to all pics*/ | |
| img { | |
| 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"); | |
| -webkit-filter: grayscale(100%); | |
| -moz-filter: grayscale(100%); | |
| -ms-filter: grayscale(100%); | |
| filter: grayscale(100%); | |
| filter: gray; /* IE 6-9 */ | |
| } | |
| img:hover { | |
| -webkit-filter: none; | |
| -moz-filter: none; | |
| -ms-filter: none; | |
| filter: none; | |
| -webkit-transition: 1s; | |
| transition: 1s; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment