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