| <style> |
| body { |
| margin: 0; |
| } |
| |
| .scroller { |
| overflow: auto; |
| width: 200px; |
| height: 500px; |
| outline: 2px solid black; |
| } |
| |
| .container { |
| width: 200px; |
| height: 1000px; |
| } |
| |
| .first { |
| position: relative; |
| top: 400px; |
| height: 100px; |
| width: 200px; |
| background-color: green; |
| } |
| |
| .second { |
| position: relative; |
| top: 400px; |
| height: 100px; |
| width: 200px; |
| background-color: yellow; |
| } |
| |
| .third { |
| position: relative; |
| top: 400px; |
| height: 100px; |
| width: 200px; |
| background-color: pink; |
| } |
| |
| .fourth { |
| position: relative; |
| top: 400px; |
| height: 100px; |
| width: 200px; |
| background-color: blue; |
| } |
| |
| .fifth { |
| position: relative; |
| top: 400px; |
| height: 100px; |
| width: 200px; |
| background-color: red; |
| } |
| </style> |
| |
| <script> |
| window.addEventListener('load', function() { |
| document.querySelector('.scroller').scrollTop = 400; |
| }); |
| </script> |
| |
| <div class="scroller"> |
| <div class="container"> |
| <div class="first"></div> |
| <div class="second"></div> |
| <div class="third"></div> |
| <div class="fourth"></div> |
| <div class="fifth"></div> |
| </div> |
| </div> |