Course recommendation:
- Kabla kwenye widows
- Pya kwenye alignContent
- Rudi kufikia ukweli Kitu cha HTML DOM Style
Style zIndex property
Definition and usage
zIndex
Property sets or returns the stacking order of the positioned element.
Tip:An element with a higher stacking order (1) is always in front of another element with a lower stacking order (0). Positioning element is Set to:relative
,absolute
or fixed
of the elements.
Tip:This property is very useful if you want to create overlapping elements.
See also:
CSS Tutorial:Tukio la ukitumia 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
Returns 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: | String representing the stacking order of an element. |
CSS Version: | CSS2 |
Mwongozo wa kufikia kwa wasaidizi wa kiburi
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Mwongozo | Mwongozo | Mwongozo | Mwongozo | Mwongozo |
- Kabla kwenye widows
- Pya kwenye alignContent
- Rudi kufikia ukweli Kitu cha HTML DOM Style