z-index
The CSS z-index property controls the stacking order of overlapping elements — which one appears in front. A higher z-index sits on top of a lower one.
Web
z-index only works on elements whose position is set to relative, absolute, fixed, or sticky. It is essential for layering modals, dropdowns, and tooltips above page content.
Stacking can be affected by 'stacking contexts' created by certain properties, which is why a high z-index sometimes still appears behind another element.
Examples
CSS
.modal {
position: fixed;
z-index: 1000;
}Output:
Places the modal above page content because of its high z-index.