position-sticky-scrolled-remove-sibling-002.html (1132B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <link rel="author" title="Ting-Yu Lin" href="mailto:tlin@mozilla.com"> 4 <link rel="author" title="Mozilla" href="https://www.mozilla.org/"> 5 <link rel="help" href="https://drafts.csswg.org/css-position/#sticky-pos"> 6 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1612561"> 7 <link rel="match" href="../../reference/ref-filled-green-100px-square.xht"> 8 <meta name="assert" content="This test verifies that there is no vertical scrollbar after removing the sibling that overflows the scroll container"> 9 10 <style> 11 #scroll { 12 width: 100px; 13 height: 100px; 14 overflow: auto; 15 background: green; 16 } 17 .sticky { 18 position: sticky; 19 width: 50px; 20 height: 100px; 21 top: 0; 22 margin-bottom: -100px; 23 } 24 #sibling { 25 width: 50px; 26 height: 500px; 27 background: red; 28 } 29 </style> 30 31 <p>Test passes if there is a filled green square and <strong>no red</strong>.</p> 32 <div id="scroll"> 33 <div class="sticky"></div> 34 <div id="sibling"></div> 35 </div> 36 37 <script> 38 window.onload = () => { 39 document.getElementById("scroll").scrollTop = 200; 40 document.getElementById("sibling").remove(); 41 }; 42 </script>