<!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: 0 20px;
direction: rtl;
}
</style>
</head>
<body>
<h3>CSS scroll-margin-inline property.</h3>
<p>With the direction property value set to rtl, the start of the element in the inline direction is changed from left to right, and this also affects the scroll-margin-inline 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, margin must be put on end of child element, because direction value is right-to-left.</p>
<div id="container">
<div class="blue">Blue</div>
<div class="green">Green</div>
<div class="blue">Blue</div>
<div class="green">Green</div>