position-absolute-dynamic-static-position.html (948B)
1 <!DOCTYPE html> 2 <html class='reftest-wait'> 3 <link rel="match" href="../reference/ref-filled-green-100px-square-only.html"> 4 <link rel="help" href="https://www.w3.org/TR/css-position-3/" /> 5 <meta name="assert" content="This test checks that a dynamic change in constraints calculates the static position correctly."/> 6 <script src="/common/reftest-wait.js"></script> 7 <style> 8 #container { 9 position: relative; 10 background: red; 11 12 box-sizing: border-box; 13 border: solid green 10px; 14 width: 100px; 15 height: 100px; 16 } 17 18 #target { 19 position: absolute; 20 background: green; 21 22 width: 80px; 23 height: 80px; 24 top: -10px; 25 left: -10px; 26 } 27 </style> 28 <p>Test passes if there is a filled green square.</p> 29 <div id="container"> 30 <div id="target"></div> 31 </div> 32 <script> 33 document.body.offsetTop; 34 const target = document.getElementById('target'); 35 target.style.top = 'initial'; 36 target.style.left = 'initial'; 37 document.body.offsetTop; 38 takeScreenshot(); 39 </script>