Last active
January 25, 2016 22:02
-
-
Save wrigby/b294e734b3e6f2edbd07 to your computer and use it in GitHub Desktop.
Applying CSS filters to background images
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
/* Some elements may need this to make sure they are the | |
* position parent of the child pseudo-element we'll create | |
* below | |
*/ | |
your_element { | |
position: relative; | |
} | |
/* This pseudo-element copies the background from its parent, | |
* allowing you to apply CSS filters just to the background image. | |
*/ | |
your_element::before { | |
background-image: inherit; | |
background-repeat: inherit; | |
background-size: inherit; | |
background-position: inherit; | |
position: absolute; | |
top: 0; | |
left: 0; | |
height: 100%; | |
width: 100%; | |
content: ""; | |
-webkit-filter: hue-rotate(180deg); | |
filter: hue-rotate(180deg); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment