containing-block-003

Containing block for relative positioned elements is nearest inline-block ancestor

WeasyPrint

This browser

Assertion
If the element's position is 'relative', the containing block is formed by the content edge of the nearest inline-block ancestor box.

Source

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 2 <html>
 3     <head>
 4         <title>CSS Test: Containing block for relative positioned elements is nearest inline-block ancestor</title>
 5         <link rel="author" title="Microsoft" href="http://www.microsoft.com/">
 6         <link rel="help" href="http://www.w3.org/TR/CSS21/visudet.html#containing-block-details">
 7         <meta name="flags" content="">
 8         <meta name="assert" content="If the element's position is 'relative', the containing block is formed by the content edge of the nearest inline-block ancestor box.">
 9         <style type="text/css">
10             #div1
11             {
12                 background: red;
13                 display: inline-block;
14                 height: 100px;
15                 padding: 20px;
16                 width: 100px;
17             }
18             div div
19             {
20                 background: green;
21                 height: 140px;
22                 left: -20px;
23                 position: relative;
24                 top: -20px;
25                 width: 140px;
26             }
27         </style>
28     </head>
29     <body>
30         <p>Test passes if there is no red visible on the page.</p>
31         <div id="div1">
32             <div></div>
33         </div>
34     </body>
35 </html>