Here is a bug that many front-end teams run into sooner or later.
You click a menu in the header. It opens, but only its top edge shows. The rest is hidden behind the hero banner below the header.
So you do what everyone does. You give the dropdown z-index: 9999 . Nothing changes. You try 99999 . Still nothing.
The number was never the problem. The problem is where the number lives.
Think of z-index as a version number
MDN has a helpful way to picture this:
To figure out the rendering order of stacked elements along the z-axis, think of each index value as a "version number" of sorts, where child elements represent minor version numbers underneath their parent's major version number.
Here is what that means in practice.
Say the header is version 0 and the hero banner is version 1. The dropdown sits inside the header. So its full number is not 9999. It is 0.9999.
And 0.9999 is still smaller than 1. The hero wins.
The box that holds those "minor" numbers is called a stacking context .…