fixed-pos-stacking-001.xht (1690B)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 3 <html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <title>CSS test: fixed positioning makes a stacking context</title> 6 7 <link rel="help" href="http://www.w3.org/TR/CSS22/visuren.html#z-index" title="9.9.1 Specifying the stack level: the 'z-index' property" /> 8 <link rel="help" href="http://www.w3.org/TR/CSS22/changes.html#s.9.9.1" title="C.1 Changes since the Recommendation of 7 June 2011" /> 9 <meta name="assert" content="auto The stack level of the generated box in the current stacking context is 0. If the box has 'position: fixed' or if it is the root, it also establishes a new stacking context." /> 10 <link rel="match" href="fixed-pos-stacking-001-ref.xht" /> 11 <link rel="author" title="Bert Bos" href="mailto:bert@w3.org" /> 12 13 14 <style type="text/css"> 15 div {width: 5em; height: 2em} 16 17 /* absolute with 'z-index: auto' does not create a stacking context */ 18 #absolute {position: absolute; left: 1em; top: 3em; background: green} 19 #absolute div {position: absolute} 20 #absolute div div {position: absolute; z-index: -1; background: red} 21 22 /* fixed with 'z-index: auto' *does* create a stacking context */ 23 #fixed {position: fixed; left: 10em; top: 3em; background: red} 24 #fixed div {position: absolute} 25 #fixed div div {position: absolute; z-index: -1; background: green} 26 </style> 27 </head> 28 29 <body> 30 <p>There should be no red.</p> 31 32 <div id="absolute"> 33 <div> 34 <div></div> 35 </div> 36 </div> 37 38 <div id="fixed"> 39 <div> 40 <div></div> 41 </div> 42 </div> 43 </body> 44 </html>