Skip to content

Instantly share code, notes, and snippets.

@jrsalunga
Created January 11, 2013 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrsalunga/4507054 to your computer and use it in GitHub Desktop.
Save jrsalunga/4507054 to your computer and use it in GitHub Desktop.
How To Work With Transparent Colors And Images In CSS Think about a div with a few paragraphs inside. Maybe you want the background of the div to be semi-transparent to allow what’s behind it to show through. Odds are you’d still like the text inside to be fully opaque so it’s easily read. However, because the paragraphs are children of the div,…
.element {
position:relative;
z-index:1;
}
.element:before {
content:"";
position:absolute;
z-index:-0;
top:0;
bottom:0;
left:0;
right:0;
background:url("path-to-image.jpg");
opacity:0.5;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment