Is it possible to use a before element for an overlay background on a nav, like this?
.nav {
background: white;
position: fixed;
}
.nav::before {
content: '';
background: black;
position: fixed;
top: 0;
bottom: 0;
right: 0;
left: 0;
}
<nav class="nav">
Nav content
</nav>
The issue I have is that the black overlay sits above the white nav, yet I want it behind? How can this be fixed?
2
Answers
Try to use z-index, i hope that its help you 🙂
This can easily be achieved with
isolation: isolate
along with a suitable positioning and z-index on the pseudo-element: