<style> | |
.sticky { | |
position: sticky; | |
top: 0; | |
margin-bottom: 800px; | |
height: 100px; | |
} | |
</style> | |
<script> | |
onload = function() { | |
target.scrollIntoView(); | |
} | |
</script> | |
<body> | |
<div class="sticky" style="background: red;"></div> | |
<div class="sticky" style="background: green;" id="target"></div> | |
</body> | |
</html> |