When adjusting the z-index property of the parent element, I am experiencing issues with overlapping elements. Below is the HTML and CSS code:
.black_gradient{
width:100%;
height:100%;
background: linear-gradient(0deg,rgb(75, 75, 75) 20%, rgba(75,75,75,0.8) 70%, rgba(75,75,75,0.3));
position:relative;
display:block;
z-index:3;
}
.img_container{
width: 100%;
height: 100%;
margin: 0 auto;
position: relative;
z-index:-2;
display:inline-block;
}
<div class="black_gradient">
<div class="img_container">
<img src="http://i48.tinypic.com/wrltuc.jpg" />
</div>
</div>
For more details, you can visit this JSFiddler link. It seems that removing the z-index from black_gradient resolves the issue, however, I have been researching about overlapping and z-index from sources like the Mozilla Developer Page without finding a solution as to why setting the z-index causes it not to work as expected.