Skip to content

Instantly share code, notes, and snippets.

@caleywoods
Created July 4, 2017 17:10
Show Gist options
  • Save caleywoods/7d3c53763fc8ae13f633efce8a78b704 to your computer and use it in GitHub Desktop.
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 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