Style zIndex Property
- Προηγούμενη Σελίδα widows
- Επόμενη Σελίδα alignContent
- Επιστροφή στο Προηγούμενο Στρώμα Οντότητα Style του HTML DOM
Definition and usage
zIndex
Sets or returns the stacking order of a positioned element.
The element with a higher stacking order (1) is always in front of another element with a lower stacking order (0).
Tip:An element positioned is position property Set to:relative
,absolute
or fixed
of the element.
Tip:This property is very useful if you want to create overlapping elements.
See also:
CSS Tutorial:CSS Θέση
CSS Reference Manual:z-index property
Example
Example 1
Change the stacking order of the <img> element:
document.getElementById("img1").style.zIndex = "1";
Example 2
Change the z-index property value of the <div> element:
document.getElementById("myDIV").style.zIndex = "-1";
Example 3
Return the z-index property value of the <img> element:
alert(document.getElementById("img1").style.zIndex);
Syntax
Return zIndex property:
object.style.zIndex
Set zIndex property:
object.style.zIndex = "auto|number|initial|inherit"
Property value
Value | Description |
---|---|
auto | The browser determines the stacking order of an element (based on its order in the document). Default. |
number | An integer that defines the stacking order of an element. Negative values are allowed. |
initial | Sets this property to its default value. See also initial. |
inherit | Inherits this property from its parent element. See also inherit. |
Technical details
Default value: | auto |
---|---|
Return value: | A string that represents the stacking order of an element. |
CSS version: | CSS2 |
Υποστήριξη Browser
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Υποστήριξη | Υποστήριξη | Υποστήριξη | Υποστήριξη | Υποστήριξη |
- Προηγούμενη Σελίδα widows
- Επόμενη Σελίδα alignContent
- Επιστροφή στο Προηγούμενο Στρώμα Οντότητα Style του HTML DOM