position-visibility-anchors-visible-after-scroll-in-ref.html (564B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <style> 4 #scroll-container { 5 overflow: hidden scroll; 6 scrollbar-width: none; 7 width: 300px; 8 height: 100px; 9 } 10 11 #anchor { 12 width: 100px; 13 height: 100px; 14 background: orange; 15 margin-bottom: 100px; 16 } 17 18 #target { 19 width: 100px; 20 height: 100px; 21 background: green; 22 } 23 </style> 24 25 <div id="scroll-container"> 26 <div id="anchor">anchor</div> 27 </div> 28 <div id="target">target</div> 29 30 <script> 31 const scroller = document.getElementById('scroll-container'); 32 scroller.scrollTop = 0; 33 </script>