I have set a background image on the .section
class in my CSS stylesheet. The background also has an opacity effect applied to it. However, I am facing an issue where the child img
(which is a transparent png) is displaying behind the background image of the div and is also inheriting the opacity value set on the background image. How can I bring this image to the front? I attempted using z-indexes but it did not resolve the problem.
.section {
background-size: 100%;
background-color: rgba(0, 0, 0, 0.5);
background-image: url(/image/bg.png);
background-repeat: no-repeat;
position: relative;
}
.section:before {
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-image: linear-gradient(to bottom right, #000000, #000000);
opacity: 0.6;
}
.logo {
width: 100%;
}
<div class="section">
<img class="logo" src={ "imgafi2x.png"}/>
</div>