Created
July 4, 2017 17:10
-
-
Save caleywoods/7d3c53763fc8ae13f633efce8a78b704 to your computer and use it in GitHub Desktop.
CSS Background image opacity without affecting other elements inside the div (like text), using ::after. If you're not using sass/scss then move the &:after out to its own, #flag-top:after{}
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
// This is the div you want your background image to be in | |
#flag-top { | |
// Here is where the background image is added and the opacity is controlled | |
&:after { | |
content : ""; | |
display: block; | |
position: absolute; | |
top: 0; | |
left: 0; | |
background-image: url('../images/flag_topper.jpg'); | |
width: 100%; | |
height: 100%; | |
opacity : 0.2; | |
} | |
h1 { | |
color: $white; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment