relpos-calcs-007.xht (1914B)
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: Relative Positioning - overconstrained top = -bottom</title> 5 <link rel="author" title="Elika J. Etemad" href="http://fantasai.inkedblade.net/contact"/> 6 <link rel="reviewer" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" /> <!-- 2012-09-25 --> 7 <link rel="help" href="http://www.w3.org/TR/CSS21/visuren.html#relative-positioning" /> 8 <link rel="match" href="relpos-calcs-001-ref.xht" /> 9 10 <meta name="assert" content="For a relatively positioned element, if 11 neither 'top' nor 'bottom' is 'auto', used value of 'bottom' is minus the 12 value of 'top'." /> 13 <style type="text/css"> 14 div { 15 height: 80px; 16 width: 120px; 17 } 18 .outer { 19 background: green; 20 position: relative; 21 top: 50%; 22 bottom: 50%; 23 24 /* 25 div.outer's used top value is 40px 26 div.outer's used bottom value is -40px 27 div.outer's computed top value is 50% 28 div.outer's computed bottom value is 50% 29 */ 30 31 } 32 .inner { 33 background: green; 34 position: relative; 35 bottom: inherit; /* using inheritance to test computed vs. used */ 36 /* div.inner's bottom inherits div.outer's computed bottom value */ 37 } 38 .control { 39 background: red; 40 margin-top: -80px; 41 height: 120px; 42 } 43 </style> 44 </head> 45 <body> 46 <p>Test passes if there is a filled green square and <strong>no red</strong>.</p> 47 <div class="container"> 48 <div class="outer"> 49 <div class="inner"></div> 50 </div> 51 </div> 52 <div class="control"></div> 53 </body> 54 </html>