height-percentage-004

Resolving container heights when they contain absolutely positioned elements with percentage based heights

WeasyPrint

This browser

Assertion
The 'height' of the containing block of an absolutely positioned element is independent of the size of the element itself.

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: Resolving container heights when they contain absolutely positioned elements with percentage based heights</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#the-height-property">
 7         <meta name="flags" content="">
 8         <meta name="assert" content="The 'height' of the containing block of an absolutely positioned element is independent of the size of the element itself.">
 9         <style type="text/css">
10             #div1
11             {
12                 height: auto;
13                 position: relative;
14             }
15             #div1, #div3
16             {
17                 width: 2in;
18             }
19             #div2
20             {
21                 background: blue;
22                 position: absolute;
23                 height: 50%;
24             }
25             #div2, #div4
26             {
27                 width: 1in;
28             }
29             #div3
30             {
31                 height: 2in;
32             }
33             #div4
34             {
35                 background: orange;
36                 height: 1in;
37                 left: 1in;
38                 position: absolute;
39                 top: 0;
40             }
41         </style>
42     </head>
43     <body>
44         <p>Test passes if the blue and orange boxes below are the same height.</p>
45         <div id="div1">
46             <div id="div2"></div>
47             <div id="div3"></div>
48             <div id="div4"></div>
49         </div>
50     </body>
51 </html>