CSS Tutorial
An element’s stack order is specified by its z-index property.
Elements may overlap one another depending on their positioning.
An element’s stack order—which element should be positioned in front of or behind the others—is indicated by its z-index property.
Positive or negative stack order can be assigned to an element:
img {
position: absolute;
left: 0px;
top: 0px;
z-index: -1;
}
Here we see that an element with greater stack order is always above an element with a lower stack order:
Black box
Gray box
Green box
Without a z-index given, the element defined last in the HTML code will appear on top when two positioned elements overlap each other.
Same example as above, but here with no z-index specified:
Black box
Gray box
Green box
| Property | Description |
|---|---|
| z-index | Sets the stack order of an element |
CodingAsk.com is designed for learning and practice. Examples may be made simpler to aid understanding. Tutorials, references, and examples are regularly checked for mistakes, but we cannot guarantee complete accuracy. By using CodingAsk.com, you agree to our terms of use, cookie, and privacy policy.
Copyright 2010-2024 by Refsnes Data. All Rights Reserved.