position-absolute-dynamic-static-position-margin-001.html (1183B)
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 #block { 19 background: green; 20 height: 40px; 21 margin-bottom: 20px; 22 } 23 24 #target { 25 position: absolute; 26 background: green; 27 28 width: 80px; 29 height: 20px; 30 top: -10px; 31 left: -10px; 32 } 33 34 #cover { 35 position: absolute; 36 background: green; 37 38 width: 80px; 39 height: 20px; 40 top: 40px; 41 left: 0px; 42 } 43 </style> 44 <p>Test passes if there is a filled green square.</p> 45 <div id="container"> 46 <div id="block"></div> 47 <div id="target"></div> 48 <div id="cover"></div> 49 </div> 50 <script> 51 document.body.offsetTop; 52 const target = document.getElementById('target'); 53 target.style.top = 'initial'; 54 target.style.left = 'initial'; 55 document.body.offsetTop; 56 takeScreenshot(); 57 </script>