absolute-non-replaced-width-026.xht (2144B)
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: absolutely positioned non-replaced element with 'left' and 'right' not set to 'auto' and 'width' set to 'auto' - max-width, horizontal margins</title> 8 9 <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" /> 10 <link rel="help" title="10.3.7 Absolutely positioned, non-replaced elements" href="http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-width" /> 11 <link rel="help" title="10.4 Minimum and maximum widths: 'min-width' and 'max-width'" href="http://www.w3.org/TR/CSS21/visudet.html#min-max-widths" /> 12 <link rel="match" href="absolute-non-replaced-width-026-ref.xht" /> 13 14 <meta content="When 'width' is computed according to the equation and rules of section 10.3.7 and when such computed 'width' is greater than 'max-width', then the equation and rules of section 10.3.7 are applied again but this time assuming the computed 'max-width' value. Then all three properties ('width', 'left' and 'right') are not 'auto' and 'margin-left' is 'auto': in which case, the 'margin-left' get all of available, remaining horizontal space." name="assert" /> 15 16 <!-- 17 Credit must go to Boris Zbarsky for explaining this in 18 http://lists.w3.org/Archives/Public/www-style/2010Oct/0147.html 19 --> 20 21 <style type="text/css"><![CDATA[ 22 body {margin: 8px;} 23 24 div#overlapped-red 25 { 26 background-color: red; 27 color: yellow; 28 font-size: 2em; 29 height: 100px; 30 margin-left: auto; 31 margin-right: 0px; 32 width: 100px; 33 } 34 35 div#abs-pos-overlapping-green 36 { 37 background-color: green; 38 height: 100px; 39 left: 8px; 40 margin-left: auto; 41 margin-right: 0px; 42 max-width: 100px; 43 position: absolute; 44 right: 8px; 45 width: auto; 46 } 47 ]]></style> 48 49 </head> 50 51 <body> 52 53 <p>Test passes if there is a green square on the <strong>right side</strong> of this page and if there is <strong>no red</strong>.</p> 54 55 <div id="abs-pos-overlapping-green"></div> 56 57 <div id="overlapped-red">FAIL</div> 58 59 </body> 60 </html>