SyntaxStudy
Sign Up

z-index

property

Controls the stacking order of positioned elements. Higher values appear in front.

Syntax

z-index: number | auto;

Example

css
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.5);
}

.modal {
    position: fixed;
    z-index: 1001;
}

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
}

.tooltip {
    position: absolute;
    z-index: 500;
}