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