<!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;
}
.blue {
background-color: lightblue;
height: 95%;
aspect-ratio: 1/1;
}
.green {
background-color: lightgreen;
height: 80%;
aspect-ratio: 1/1;
}
.blue, .green {
margin: 2px;
display: inline-block;
scroll-snap-align: none start;
scroll-margin-inline-end: 20px;
direction: rtl;
}
</style>
</head>
<body>
<h3>CSS scroll-margin-inline-end property.</h3>
<p>With the direction property value set to right-to-left, the end of the child elements in the inline direction is changed from right to left, and this also affects the scroll-margin-inline-end property.</p>
<p>In this example, snap position is set to start in the inline direction. To put a margin of 20px where the snap position is, when direction value is right-to-left, margin must be put at the end of the child elements.</p>
<div id="container">
<div class="blue">Blue</div>
<div class="green">Green</div>
<div class="blue">Blue</div>
<div class="green">Green</div>