left-offset-position-fixed-001.xht (1829B)
1 <!DOCTYPE html> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>CSS Test: left:auto offset of position:fixed box in a position:relative containing block</title> 5 <link rel="author" title="Chris Rebert" href="http://chrisrebert.com" /> 6 <link rel="reviewer" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" /> <!-- 2015-09-17 --> 7 <link rel="help" href="http://www.w3.org/TR/CSS21/visuren.html#position-props" title="9.3.2 Box offsets: 'top', 'right', 'bottom', 'left'" /> 8 <link rel="help" href="http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-width" title="10.3.7 Absolutely positioned, non-replaced elements" /> 9 <link rel="help" href="https://drafts.csswg.org/css2/visuren.html#position-props" /> 10 <link rel="help" href="https://drafts.csswg.org/css2/visudet.html#abs-non-replaced-width" /> 11 <link rel="match" href="left-offset-position-fixed-001-ref.xht" /> 12 <meta name="assert" content="The 'left' box offset property, for fixed positioning, when set to 'auto' specifies the offset of the box from its 'static-position containing block'. Here, in this test, the 'static-position containing block' is #shifted-column and the containing block for #red is established by the viewport." /> 13 <style type="text/css"> 14 #shifted-column { 15 left: 50%; 16 width: 50%; 17 position: relative; 18 } 19 .square { 20 width: 100px; 21 height: 100px; 22 } 23 #red { 24 background-color: red; 25 position: fixed; 26 left: auto; 27 } 28 #green { 29 background-color: green; 30 position: absolute; 31 left: 50%; 32 } 33 </style> 34 </head> 35 <body> 36 <p>Test passes if there is a solid green square and <strong>no red</strong>.</p> 37 38 <div id="shifted-column"> 39 <div id="red" class="square"></div> 40 </div> 41 <div id="green" class="square"></div> 42 </body> 43 </html>