| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/x
html1/DTD/xhtml1-strict.dtd"> |
| 2 <html xmlns="http://www.w3.org/1999/xhtml"> |
| 3 <head> |
| 4 <title>CSS Test: Max-height on absolutely positioned, non-replaced eleme
nts, 'margin-top' and 'margin-bottom' set to '0'</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-r
eplaced-height" /> |
| 8 <link rel="match" href="absolute-non-replaced-height-003-ref.xht
" /> |
| 9 |
| 10 <meta name="flags" content="" /> |
| 11 <meta name="assert" content="When 'top' and 'height' are 'auto' and 'bot
tom' is not 'auto', then the height is based on the content (and such height can
be constrained by a max-height declaration) and then set 'auto' values for 'mar
gin-top' and 'margin-bottom' to 0, and solve for 'top' " /> |
| 12 <style type="text/css"> |
| 13 #div1 |
| 14 { |
| 15 border: solid black; |
| 16 height: 3in; |
| 17 position: relative; |
| 18 width: 3in; |
| 19 } |
| 20 div div |
| 21 { |
| 22 background: blue; |
| 23 bottom: 1in; |
| 24 height: 2in; |
| 25 margin-bottom: auto; |
| 26 margin-top: auto; |
| 27 max-height: 1in; |
| 28 position: absolute; |
| 29 top: auto; |
| 30 width: 100%; |
| 31 } |
| 32 |
| 33 /* |
| 34 |
| 35 auto (to solve) : top |
| 36 + |
| 37 auto (to solve): margin-top |
| 38 + |
| 39 0 : border-top-width |
| 40 + |
| 41 0 : padding-top |
| 42 + |
| 43 2in : height (will be constrained to use 1in by max-height) |
| 44 + |
| 45 0 : padding-bottom |
| 46 + |
| 47 0 : border-bottom-width |
| 48 + |
| 49 auto (to solve): margin-bottom |
| 50 + |
| 51 1in : bottom |
| 52 ============= |
| 53 3in : height of containing block |
| 54 |
| 55 |
| 56 " |
| 57 'top' is 'auto', 'height' and 'bottom' are not 'auto', |
| 58 then set 'auto' values for 'margin-top' and 'margin-bottom' to 0, |
| 59 and solve for 'top' |
| 60 " |
| 61 |
| 62 so this brings: |
| 63 |
| 64 auto (to solve) : top |
| 65 + |
| 66 0 (set): margin-top |
| 67 + |
| 68 0 : border-top-width |
| 69 + |
| 70 0 : padding-top |
| 71 + |
| 72 1in (constrained) : height |
| 73 + |
| 74 0 : padding-bottom |
| 75 + |
| 76 0 : border-bottom-width |
| 77 + |
| 78 0 (set): margin-bottom |
| 79 + |
| 80 1in : bottom |
| 81 ============= |
| 82 3in : height of containing block |
| 83 |
| 84 So, top must use 1in in order to balance the equation |
| 85 |
| 86 */ |
| 87 </style> |
| 88 </head> |
| 89 <body> |
| 90 <p>Test passes if a blue rectangle is <strong>vertically centered</stron
g> in an hollow black square.</p> |
| 91 <div id="div1"> |
| 92 <div></div> |
| 93 </div> |
| 94 </body> |
| 95 </html> |
| OLD | NEW |