absolute-non-replaced-height-012.xht (1842B)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>CSS Test: Absolutely positioned, non-replaced elements, solve for 'bottom'</title> 5 <link rel="author" title="Microsoft" href="http://www.microsoft.com/" /> 6 <link rel="reviewer" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" /> <!-- 2012-08-31 --> 7 <link rel="help" href="http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-height" /> 8 <link rel="match" href="absolute-non-replaced-height-003-ref.xht" /> 9 10 <meta name="assert" content="When 'margin-top' and 'margin-bottom' are set to '0' the 'bottom' value resolves to the remaining space within the containing block." /> 11 <style type="text/css"> 12 #div1 13 { 14 border: solid black; 15 height: 3in; 16 position: relative; 17 width: 3in; 18 } 19 div div 20 { 21 position: absolute; 22 top: 1in; 23 bottom: auto; 24 height: 1in; 25 margin-top: auto; 26 margin-bottom: auto; 27 background: blue; 28 width: 100%; 29 } 30 31 /* 32 " 33 'bottom' is 'auto', 'top' and 'height' are not 'auto', 34 then set 'auto' values for 'margin-top' and 'margin-bottom' to 0 35 and solve for 'bottom' 36 " 37 38 Therefore, bottom used value must be 1in 39 */ 40 </style> 41 </head> 42 <body> 43 <p>Test passes if a blue rectangle is <strong>vertically centered</strong> in an hollow black square.</p> 44 <div id="div1"> 45 <div></div> 46 </div> 47 </body> 48 </html>