x
 
<!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 属性</h3>
<p>当 direction 属性值设置为从右到左时,子元素在行内方向上的结束位置从右侧变为左侧,这也会影响 scroll-margin-inline-end 属性。</p>
<p>在此例中,吸附位置设置为在行内方向上开始。为了在方向值为从右到左时,在吸附位置设置 20 像素的外边距,必须将外边距设置在子元素的末端。</p>
<div id="container">
  <div class="blue">Blue</div>
  <div class="green">Green</div>
  <div class="blue">Blue</div>
  <div class="green">Green</div>
  <div class="blue">Blue</div>
  <div class="green">Green</div>
  <div class="blue">Blue</div>
</div>
</body>
</html>