box-offsets-abs-pos-001.xht (1944B)
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: box offsets - containing block for absolute positioned boxes</title> 8 9 <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" /> 10 <link rel="help" title="9.3.2 Box offsets: 'top', 'right', 'bottom', 'left'" href="http://www.w3.org/TR/CSS21/visuren.html#position-props" /> 11 <meta content="image" name="flags" /> 12 <meta content="Box offsets (bottom, left, right, top) for an absolutely positioned box refers to the padding box of its nearest positioned ancestor; such padding box forms and acts as the containing block of the absolutely positioned box." name="assert" /> 13 14 <style type="text/css"><![CDATA[ 15 body {margin: 8px;} 16 17 #nearest-positioned-ancestor 18 { 19 background-color: yellow; /* padding box will be yellow */ 20 border: orange solid 50px; /* border box will be orange */ 21 height: 100px; /* a bright green square 100px by 100px image will serve as content box */ 22 margin-left: 100px; 23 padding: 50px; 24 position: relative; 25 top: auto; 26 width: 100px; 27 } 28 29 div > div 30 { 31 background-color: blue; 32 color: white; 33 height: 25px; 34 position: absolute; 35 width: 25px; 36 } 37 38 div#top-left 39 { 40 left: 0px; 41 top: 0px; 42 } 43 44 div#top-right 45 { 46 right: 0px; 47 top: 0px; 48 } 49 50 div#bottom-left 51 { 52 bottom: 0px; 53 left: 0px; 54 } 55 56 div#bottom-right 57 { 58 bottom: 0px; 59 right: 0px; 60 } 61 ]]></style> 62 63 </head> 64 65 <body> 66 67 <p>Test passes if there is a blue square at each corner of the yellow square.</p> 68 69 <div id="nearest-positioned-ancestor"><img src="support/100x100-lime.png" alt="Image download support must be enabled" /> 70 <div id="top-left">TL</div> 71 <div id="top-right">TR</div> 72 <div id="bottom-left">BL</div> 73 <div id="bottom-right">BR</div> 74 </div> 75 76 </body> 77 </html>