I've been programming websites for a while and I've always avoided using z-index because when I asked my web development teacher about his he just laughed.
I've had a few dabbles at trying to implement it myself with no real guidance and up until till now I haven't figured out why it didn't work.
On the W3Schools info about z-indexing there is one note that is not very prominent that should be the first thing they speak about.
z-index only works on positioned elements (position:absolute, position:relative, or position:fixed).
If I had known about this, I would've been using z-indexing a whole lot more.
I hope you find this helpful.