给滚动容器增加样式
<div class="scroll-container">
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
<div>1</div>
</div>
.scroll-container {
height: 50px;
overflow: auto;
scroll-behavior: smooth;
-webkit-overflow-scrolling: touch;
}
demo:
https://stackblitz.com/edit/scroll-smooth
关键样式:
scroll-behavior: smooth;
-webkit-overflow-scrolling: touch;