dynamic-top-change-005a

Inheriting 'top' changes from abspos grandparent (variant: block parent)

WeasyPrint

This browser

Flags
dom
Assertion
The position of a positioned element which inherits its 'top' value from its relatively positioned parent changes when the parent's 'top' value is changed.

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: Inheriting 'top' changes from abspos grandparent (variant: block parent)</title>
 5   <link rel="author" title="Boris Zbarsky" href="mailto:bzbarsky@mit.edu">
 6   <link rel="author" title="L. David Baron" href="http://dbaron.org/">
 7   <link rel="reviewer" title="Elika J. Etemad" href="http://fantasai.inkedblade.net/contact">
 8   <link rel="help" href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">
 9   <link rel="help" href="http://www.w3.org/TR/CSS21/visuren.html#position-props">
10   <link rel="help" href="http://www.w3.org/TR/CSS21/visuren.html#propdef-position">
11   <meta name="flags" content="dom">
12   <meta name="assert" content="The position of a positioned element which inherits its 'top' value from its relatively positioned parent changes when the parent's 'top' value is changed.">
13   <style type="text/css">
14     .testDiv { position: relative; width: 100px; height: 100px; }
15     #green { top: 100px; background: green; }
16     #red { top: inherit; background: red; display: block; }
17     #parent { position: relative; }
18     body > p { position: absolute; font-size: medium; }
19     #grandparent { position: absolute; top: 0; }
20     body { font-size: 0; line-height: 0; position: relative; }
21   </style>
22   <script type="text/javascript">
23     window.onload = function() {
24       document.body.offsetWidth;
25       document.getElementById("parent").style.top = "50px";
26     }
27   </script>
28  </head>
29  <body>
30    <p>There should be no red.</p>
31    <div id="grandparent">
32      <div id="parent">
33        <span id="red" class="testDiv"></span>
34      </div>
35    </div>
36    <div id="green" class="testDiv"></div>
37  </body>
38 </html>