• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

13. Positioning HTML Elements > 13.5. Adjusting Positioned Element Stacking Ord...

Adjusting Positioned Element Stacking Order (z-order)

NN 4, IE 4

Problem

You want to control the way an overlapping element appears in front of or behind another element.

Solution

You can either use the setZIndex( ) function from the DHTML library (Recipe 13.3) for backward-compatibility or, for all browsers that support the style property of elements, adjust the style.zIndex property directly:

document.getElementById("myLayer").style.zIndex = "100";

Discussion

Turning an element into a positioned element automatically raises it to a layer in front of the main document content. Unless the background of a layer is set to a color or image, the element’s background is transparent by default, allowing content underneath to be visible in the blank spaces.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint