absolute-non-replaced-height-007.xht (2699B)
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, shrink-to-fit solve for top</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-007-ref.xht" /> 9 10 <meta name="flags" content="ahem" /> 11 <meta name="assert" content="Verify that height is based on the overall height of the content, 'margin-top' and 'margin-bottom' when set to 'auto' are solved to '0' and solve for 'top', when 'top' and 'height' are both 'auto' and 'bottom' is not 'auto'." /> 12 <link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> 13 <style type="text/css"> 14 #div1 15 { 16 color: orange; 17 font: 100px/1 Ahem; 18 height: 300px; 19 position: relative; 20 width: 200px; 21 } 22 div div 23 { 24 background: blue; 25 bottom: 200px; 26 height: auto; 27 margin-bottom: auto; 28 margin-top: auto; 29 position: absolute; 30 top: auto; 31 width: 100%; 32 } 33 34 /* 35 36 auto (to solve) : top 37 + 38 auto (to solve): margin-top 39 + 40 0 : border-top-width 41 + 42 0 : padding-top 43 + 44 auto (to solve) : height 45 + 46 0 : padding-bottom 47 + 48 0 : border-bottom-width 49 + 50 auto (to solve): margin-bottom 51 + 52 200px : bottom 53 ============= 54 300px : height of containing block 55 56 " 57 'top' and 'height' are 'auto' and 'bottom' is not 'auto', 58 then the height is based on the content per 10.6.7, 59 set 'auto' values for 'margin-top' and 'margin-bottom' to 0, 60 and solve for 'top' 61 " 62 63 so this brings: 64 65 66 auto (to solve) : top 67 + 68 0 (solved): margin-top 69 + 70 0 : border-top-width 71 + 72 0 : padding-top 73 + 74 100px (solved: based on content) : height 75 + 76 0 : padding-bottom 77 + 78 0 : border-bottom-width 79 + 80 0 (solved) : margin-bottom 81 + 82 200px : bottom 83 ============= 84 300px : height of containing block 85 86 so top will use 0px 87 88 */ 89 90 </style> 91 </head> 92 <body> 93 <p>Test passes if the orange and blue squares have the <strong>same height</strong>.</p> 94 <div id="div1"> 95 <div>X</div> 96 </div> 97 </body> 98 </html>