<!DOCTYPE html>
<html>
<head>
<style>
#container {
width: 80%;
aspect-ratio: 2/1;
margin: auto;
border: solid black 2px;
overflow-x: hidden;
overflow-y: scroll;
scroll-snap-type: y mandatory;
scroll-padding-top: 0;
}
.blue {
background-color: lightblue;
width: 95%;
aspect-ratio: 3/1;
}
.green {
background-color: lightgreen;
width: 80%;
aspect-ratio: 4/1;
}
.blue, .green {
margin: 2px;
scroll-snap-align: start;
}
</style>
</head>
<body>
<h1>Change scroll-padding-top property with JavaScript</h1>
<p>Try first to scroll to see how the scroll snaps on start of elements on y-axis.</p>
<p>Now, click button, click inside the container, and see how scrolling behavior has changed. The elements now snap on start of elements with a 20px distance from the container.</p>