I want to make a piece of content in HTMLCSS with the background-image having a grey background(filter) over it this is fairly simple but the content does also get the grey filter , i gave everything a position relative and did the following:
background: lowest z-index filter: middle z-index content: highest z-index (shouldnt be affected by the middle z-index in my opinion) but the thing is: it does, the middle z-index affects my highest z-index and i do not understand why this is the code i wrote ( sample code because the other code was too big)
html:
<body>
<div class="filter">
<div class="content">
<h1>Hello Stackoverflow</h1>
<p>Please help me view this without the filter effect affecting the content ( this part)</p>
</div>
</div>
</body>
css:
body{
background-image: url('the-doors.jfif');
position: relative;
z-index: 1;
}
.filter{
background-color: grey;
opacity: 40%;
position: relative;
z-index: 2;
}
.content{
color: green;
font-size: 3.0em;
position: relative;
z-index: 3;
}
can somebody please help me explain why the content also gets the grey filter effect although it has a higher z-index