The z-index
property designates the stacking order of an element.
z-index
only works when its element has a position assigned (position: absolute
, position: fixed
, position: relative
, or position: sticky
) and on flex elements (items inside display: flex
elements). Elements with a higher z-index
value display in front of those with a lower value.
.classname {
position:relative;
z-index:1;
}
auto
Default value. The stacking order of the element is set to that of its parents.
number
Positive and negative numbers are allowed. Sets the stacking order of the item.
initial
Sets the property to its default value.
inherit
Inherits this property’s value from its parent item.
Have a code example of z-index
? Submit a codepen.io demo and we'll showcase it here ↴