dynamic-top-change-004

Inheriting 'top' changes from abspos parent

WeasyPrint

This browser

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