<!doctype HTML> | |
<style> | |
.spacer { | |
width: 150px; | |
height: 3000px; | |
background: lightblue; | |
} | |
#container { | |
contain: style layout; | |
width: 150px; | |
height: 150px; | |
background: lightgreen; | |
} | |
#target { | |
width: 100px; | |
height: 100px; | |
background: green; | |
} | |
</style> | |
<div class="spacer"></div> | |
<div id="container"><div id="target"></div></div> | |
<script> | |
target.scrollIntoView(); | |
</script> |