javascript zIndex attribute


  Translation results:

UK[ˈɪndeks] US[ˈɪnˌdɛks]

n.index;<number>index;indication;sign

vt.To index...;to index...; [Economics] Adjustment by living index (wages, prices, etc.)

vi.[Mechanics] Transposition

Third person singular: indexes Plural: indices indexes Present participle: indexing Past tense: indexed past participle: indexed

javascript zIndex attributesyntax

Function:Set the stacking order of elements.

Syntax: Object.style.zIndex=auto|number

Notes: Elements can have negative z-index attribute values. Z-index only works on positioned elements (such as position:absolute;)

javascript zIndex attributeexample

<html>
<head>
<style type="text/css">
#img1
{
position:absolute;
left:0px;
top:0px;
z-index:-1
}
</style>
<script type="text/javascript">
function changeStackOrder()
{
document.getElementById("img1").style.zIndex="1";
}
</script>
</head>
<body>

<h1>This is a Heading</h1>

<img id="img1" src="http://img.php.cn/upload/article/000/005/656/5af270fd37755429.jpg" width="100" height="180">

<p>Default z-index is 0. Z-index -1 has lower priority.</p>

<input type="button" onclick="changeStackOrder()" value="Change stack order" />

</body>
</html>

Run instance »

Click the "Run instance" button to view the online instance

Home

Videos

Q&A