fixed-pos-stacking-001-ref.xht (1096B)
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 Reference File</title> 6 <link rel="author" title="Bert Bos" href="mailto:bert@w3.org" /> 7 8 <style type="text/css"> 9 div {width: 5em; height: 2em} 10 11 /* absolute with 'z-index: auto' does not create a stacking context */ 12 #absolute {position: absolute; left: 1em; top: 3em; background: green} 13 #absolute div {position: absolute} 14 #absolute div div {position: absolute; z-index: -1; background: green} 15 16 /* fixed with 'z-index: auto' *does* create a stacking context */ 17 #fixed {position: fixed; left: 10em; top: 3em; background: green} 18 #fixed div {position: absolute} 19 #fixed div div {position: absolute; z-index: -1; background: green} 20 </style> 21 </head> 22 23 <body> 24 <p>There should be no red.</p> 25 26 <div id="absolute"> 27 <div> 28 <div></div> 29 </div> 30 </div> 31 32 <div id="fixed"> 33 <div> 34 <div></div> 35 </div> 36 </div> 37 </body> 38 </html>