<!DOCTYPE html>
<html>
<head>
<style>
#container {
width: 80%;
aspect-ratio: 2/1;
margin: auto;
border: solid black 2px;
overflow-x: scroll;
overflow-y: hidden;
white-space: nowrap;
scroll-snap-type: x mandatory;
scroll-padding-inline-end: 0;
}
.blue {
background-color: lightblue;
height: 95%;
aspect-ratio: 3/2;
}
.green {
background-color: lightgreen;
height: 80%;
aspect-ratio: 4/3;
}
.blue, .green {
display: inline-block;
margin: 2px;
scroll-snap-align: none end;
}
</style>
</head>
<body>
<h1>Change scroll-padding-inline-end property with JavaScript</h1>
<p>Try first to scroll to see how the scroll snaps on start of elements in the inline direction.</p>
<p>Now, click button, click inside the container, and see how scrolling behaviour has changed. The elements still snap on end of element like before, but now with a 20px distance in the inline direction from the end of the container to the child elements.</p>
<button onclick="myFunction()">Try it</button>
<div id="container">
<div class="blue"></div>