z-index-dynamic-001.xht (1630B)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 3 <html xmlns="http://www.w3.org/1999/xhtml"> 4 5 <head> 6 7 <title>CSS Test: Z-index - dynamically setting z-index to bring an element from back to in front of</title> 8 9 <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" /> 10 <link rel="help" title="Section 9.9.1 Specifying the stack level: the 'z-index' property" href="http://www.w3.org/TR/CSS21/visuren.html#z-index" /> 11 <link rel="match" href="../reference/ref-filled-green-100px-square.xht" /> 12 <meta http-equiv="Content-Script-Type" content="text/javascript" /> 13 <meta content="dom" name="flags" /> 14 <meta content="Setting the 'z-index' property of a positioned element can bring it from behind the surface on a lower stack level to a greater stack level passing it in front of another element painted on the surface." name="assert" /> 15 16 <style type="text/css"><![CDATA[ 17 #test 18 { 19 background-color: green; 20 display: block; 21 z-index: -1; 22 } 23 24 #red-layer 25 { 26 background-color: red; 27 top: -100px; 28 z-index: auto; 29 } 30 31 #test, #red-layer 32 { 33 height: 100px; 34 position: relative; 35 width: 100px; 36 } 37 ]]></style> 38 39 <script type="text/javascript"><![CDATA[ 40 function fromBottomToTopOfStack() 41 { 42 document.getElementById("test").style.zIndex = 1; 43 } 44 ]]></script> 45 46 </head> 47 48 <body onload="fromBottomToTopOfStack();"> 49 50 <p>Test passes if there is a filled green square and <strong>no red</strong>.</p> 51 52 <div><span id="test"></span></div> 53 54 <div id="red-layer"></div> 55 56 </body> 57 </html>