XML technologies / CSS / Advanced websites with CSS / CSS property reference / z-index
(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)
The property z-index describes the position of an element not positioned with static in a stack of overlapping elements.
Elements positioned with static or not positioned at all are always below elements positioned with absolute or relative within the same stacking context. Their z-index is 0. Elements in the same stacking context with equal values of z-index are stacked in HTML source order, the first at the bottom and the last at the top.
Inherited: no
See also: position
Value
A positive integer or the constant auto. Higher numeric values place the element higher in the stack.
With the constant auto the element behaves as if it had a z-index of 0. It does not create a new stacking context, but joins an existing one at the lowest position.
Default value: auto
Compatibility
CSS version: 2
Works in all CSS-capable browsers, including Netscape 4.
Example
The following rule positions the element with the ID hauptmenue ten pixels from the browser window’s top-left corner. If elements overlap, its z-index makes it float above elements with a lower z-index:
#hauptmenue {
position: absolute;
top: 10px;
left: 10px;
width: 100px;
height: 300px;
z-index: 10;
}
Copyright © 2006 of the German translation, dpunkt.verlag GmbH
You may print the online version for your private use.
Otherwise, this chapter from “CSS − Anspruchsvolle Websites mit Cascading Stylesheets” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
dpunkt.verlag GmbH, Ringstraße 19, 69115 Heidelberg