Microsoft HomeproductssearchsupportshopWrite Us   Microsoft Home
Magazine
 |  Community
 |  Workshop
 |  Tools & Samples
 |  Training
 |  Site Info

Workshop  |  DHTML, HTML & CSS

z-index Attribute | zIndex Property


Sets or retrieves the stacking order of positioned objects.

Syntax

HTML{ z-index: "auto" | sOrder }
Scriptingobject.style.zIndex [ = sOrder]

Possible Values

autoBottom-to-top stacking in the order that the objects for which z-index is set appear in the HTML source.
sOrderString specifying the order as an integer or as "auto".

The property is read/write with a default value of auto; the CSS attribute is not inherited.

Remarks

Positive z-index values are positioned above a negative (or lesser value) z-index. Two objects with the same z-index are stacked according to source order.

Example

The following examples demonstrate use of both the z-index attribute and the zIndex property to change the stacking order of objects.

The sample below uses an inline style sheet to set the stacking order.

Sample Code

<IMG SRC="cone.jpeg" STYLE="position:absolute; top:100; left:100; z-index:4">
<DIV STYLE="position:absolute; top:100; left:100; color:red;
    background-color:beige;font-weight:bold; z-index:1">
. . . </DIV>

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

The sample below uses inline scripting to set the stacking order.

<IMG ID="cone" SRC="cone.jpeg"
    STYLE="position:absolute;top:10px;left:10px;"
    onclick="cone.style.zIndex=1; sphere.style.zIndex=2">
<IMG ID="sphere" SRC="sphere.jpeg"
    STYLE="position:absolute;top:1px;left:1px;"
    onclick="cone.style.zIndex=2; sphere.style.zIndex=1">

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To


Does this content meet your programming needs? Write us!

Back to topBack to top

© 1998 Microsoft Corporation. All rights reserved. Terms of use.

 

Magazine Home
Ask Jane
DHTML Dude
Extreme XML
For Starters
More or Hess
Servin' It Up
Site Lights
Web Men Talking
Member Community Home
Benefits: Freebies & Discounts
Benefits: Promote Your Site
Benefits: Connect with Your Peers
Benefits at a Glance
Online Special-Interest Groups
Your Membership
SBN Stores
Join Now
Workshop Home
Essentials
Content & Component Delivery
Component Development
Data Access & Databases
Design
DHTML, HTML & CSS
Extensible Markup Language (XML)
Languages & Development Tools
Messaging & Collaboration
Networking, Protocols & Data Formats
Reusing Browser Technology
Security & Cryptography
Server Technologies
Streaming & Interactive Media
Web Content Management
Workshop Index
Tools & Samples Home
Tools
Samples, Headers, Libs
Images
Sounds
Style Sheets
Web Fonts
Training Home
SBN Live Seminars
SBN Live Chats
Courses
Peer Support
CD-ROM Training
Books & Training Kits
Certification
SBN Home
New to SBN?
What's New on SBN
Site Map
Site Search
Glossary
Write Us
About This Site