HTML DOM zIndex Property
Complete Style Object Reference
Definition and Usage
The zIndex property sets the stack order of an element.
An element with
greater stack order is always in front of another element with lower stack
order.
Syntax
Object.style.zIndex=auto|number
|
Possible Values
Value |
Description |
auto |
The stack order is equal to its parents |
number |
A number that defines the stack order of the element |
Tips and Notes
Tip: Elements can have negative stack orders.
Note: zIndex only works on elements that have been positioned, like
position:absolute;
Example
The following example changes the stack order of an element:
<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="bulbon.gif" 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>
|
Try-It-Yourself Demos
zIndex
- Change the stack order of an element
Complete Style Object Reference
Learn XML with <oXygen/> XML Editor - Free Trial!
|
|
oXygen helps you learn to define,
edit, validate and transform XML documents. Supported technologies include XML Schema,
DTD, Relax NG, XSLT, XPath, XQuery, CSS.
Understand in no time how XSLT and XQuery work by using the intuitive oXygen debugger!
Do you have any XML related questions? Get free answers from the oXygen
XML forum
and from the video
demonstrations.
Download a FREE 30-day trial today!
|
|