Skip to content

Instantly share code, notes, and snippets.

@AlvisonHunterArnuero
Created October 3, 2024 05:47
Show Gist options
  • Save AlvisonHunterArnuero/a7779e09f2db4f3f63b2268e68c0c1a4 to your computer and use it in GitHub Desktop.
Save AlvisonHunterArnuero/a7779e09f2db4f3f63b2268e68c0c1a4 to your computer and use it in GitHub Desktop.
Set the background image of a body of a html page to 50%, using pseudo-element ::before and the opacity: 0.5; property
body::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image: url('place-your-image-url-here.jpg');
background-size: cover;
background-position: center;
opacity: 0.5;
z-index: -1;
}
body * {
position: relative;
z-index: 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment