So I have looked in many different SO questions and google results but I have not found the exact information I have been looking for.
I have a background-image that I wanted to do a transparent color overlay for. The common answer is to just use both the background-image and color properties, or even on the same line. But neither of those options work for me. It simply will NOT allow me to have both. Even using a linear gradient instead of color does not work.
The only thing that I have gotten to work is to use a parent/child div with image/color respectively. Which is confusing.
The parent has the image, but the color overlay is...the child? If there is no opacity on the child's color, then I can't see the image at all.
Can someone please help me understand the relationship and why I can't do both?
.color {
width: 100%;
height: 50vh;
background-color: hsl(277, 64%, 61%);
opacity: 50%;
}
.hero {
background-image: url("https://via.placeholder.com/800");
background-size: cover;
background-repeat: no-repeat;
width: 100%;
height: 100%;
}
<div class="hero">
<div class="color"></div>
</div>