top-offset-percentage-001

Top offset using percentage

WeasyPrint

This browser

Assertion
Percentage offset values for the 'top' property are based off the height of the containing block.

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: Top offset using percentage</title>
 5         <link rel="author" title="Microsoft" href="http://www.microsoft.com/">
 6         <link rel="help" href="http://www.w3.org/TR/CSS21/visuren.html#propdef-top">
 7         <link rel="help" href="http://www.w3.org/TR/CSS21/visuren.html#position-props">
 8         <meta name="flags" content="">
 9         <meta name="assert" content="Percentage offset values for the 'top' property are based off the height of the containing block.">
10         <style type="text/css">
11             #div1
12             {
13                 border: solid black;
14                 height: 200px;
15                 position: relative;
16                 width: 100px;
17             }
18             div div
19             {
20                 height: 50px;
21                 position: absolute;
22                 width: 50px;
23             }
24             #test
25             {
26                 background: green;
27                 top: 50%;
28             }
29             #reference
30             {
31                 background: red;
32                 bottom: 50px;
33             }
34         </style>
35     </head>
36     <body>
37         <p>Test passes if the green box is not in any of the corners of the black box and there is no red visible on the page.</p>
38         <div id="div1">
39             <div id="reference"></div>
40             <div id="test"></div>
41         </div>
42     </body>
43 </html>