Gets or sets the stacking order of positioned objects.
HRESULT IHTMLCSSStyleDeclaration::get_zIndex(VARIANT *p);HRESULT IHTMLCSSStyleDeclaration::put_zIndex(VARIANT v);
- Pointer to a variable of type VARIANT of type VT_BSTR or VT_I4 that receives one of the values listed in Possible Values.
- VARIANT of type VT_BSTR or VT_I4 that specifies one of the values listed in Possible Values.
auto Default. String that specifies the stacking order of the positioned objects based on the order in which the objects appear in the HTML source. order Integer that specifies the position of the object in the stacking order.
Returns S_OK if successful, or an error value otherwise.
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. A positive value positions the element above text that has no defined z-index, and a negative value positions it below. Set this parameter to NULL to remove the attribute.
The IHTMLCSSStyleDeclaration::zIndex property only applies to objects that have the IHTMLCSSStyleDeclaration::position property set to
The property does not apply to windowed controls, such as select objects.
Input from pointing devices, such as a mouse, does not penetrate through overlapping elements even if the elements are not visible. This is also true for positioned elements with a negative z-index unless:
- The parent is a scrolling container (that is, its IHTMLCSSStyleDeclaration::overflow property is set to
- The parent is positioned (that is, its IHTMLCSSStyleDeclaration::position property is set to
As of Microsoft Internet Explorer 5.5, the iframe object is windowless and supports the zIndex property. In earlier versions of Internet Explorer, the iframe object is windowed and, like all windowed controls, ignores the zIndex property. If you maintain Web pages that were designed for earlier versions of Internet Explorer that do not support the zIndex property, you might want to redesign the pages, especially if the pages contain iframe objects that are stacked on top of windowed controls, such as select objects. You can use the IHTMLCSSStyleDeclaration::visibility attribute to hide windowed controls that you want an iframe object to overlap.
As of Internet Explorer 7, the select property is windowless and can make use of the z-index attribute and the IHTMLCSSStyleDeclaration::zIndex property.
Internet Explorer 8 and later. When you access a property that has not been explicitly set, Internet Explorer returns the default value of the property. The default value of the zIndex property for the currentStyle object depends on the document compatibility mode used to display the Web page. When a page is displayed in IE8 Standards mode, the default value is
auto. The default value is
0in IE7 Standards mode and an empty string (
"") in IE5 (Quirks) mode. Applications that rely on specific default values for the zIndex property of the currentStyle object should be modified to take the document compatibility mode into account.