A background image needs to be faded, without also fading the actual content sitting on top of it.
⚡ Quick Fix (TL;DR)
The Culprit: Setting opacity directly on a section fades everything inside it, including the text and content, not just the background.
The Fix: Create a separate image layer using a pseudo-element, so its opacity can be controlled independently of the real content.
.example {
position: relative;
isolation: isolate;
}
.example::before {
content: "";
position: absolute;
inset: 0;
background-image: url("IMAGE-URL-HERE");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
opacity: 0.25;
z-index: -1;
} Was this helpful? Thanks for the feedback!
Tagged in :
More from the field
Bisect to an Empty Baseline Before Trusting Any Single Theory
.
Multiple plausible-sounding theories for a bug each turned out to be wrong when actually tested – time was spent building fixes…
A Security Dashboard’s Activity Log Can Lag a Full Day Behind Real Time
.
Trying to check a security tool’s activity log for an event that had just happened showed nothing at all.