z-index not indexing properly
This question already has an answer here:
Alright, so this code generates two blocks in a div. The top block should go over the bottom block because the top has a higher z-index, but when I give the bottom block a margin-top: -30px it goes above the top block.
How do I get the top block to go above the bottom block?
z-index property only applies to positioned elements.
You could add
position: relative and it will work as expected (example).
The default value of the
position property is
static, which is why it wasn’t working.