| <!DOCTYPE html> |
| <style> |
| body { |
| margin: 0px; |
| } |
| |
| .scroller { |
| overflow: scroll; |
| width: 200px; |
| height: 600px; |
| } |
| |
| .box { |
| background: rgba(0, 255, 0, 0.9); |
| position: relative; |
| width: 185px; |
| height: 50px; |
| top: 20px; |
| } |
| |
| .indicator { |
| position: absolute; |
| width: 185px; |
| height: 50px; |
| background: red; /* covered up by .box when working */ |
| } |
| |
| .container { |
| width: 100%; |
| height: 1000px; |
| background: grey; |
| } |
| </style> |
| |
| <div id="scroller" class="scroller"> |
| <div class="container"> |
| <div class="indicator"></div> |
| <div class="box"></div> |
| </div> |
| </div> |
| |
| <script> |
| let scroller = document.getElementById('scroller'); |
| scroller.scrollTop = 20; |
| </script> |