z-index property only works on elements with a
position value other than
position: relative;, or
There is also
position: sticky; that is supported in Firefox, is prefixed in Safari, worked for a time in older versions of Chrome under a custom flag, and is under consideration by Microsoft to add to their Edge browser.