滚动条样式
.bar {
scrollbar-color: hsla(220, 4%, 58%, .3) transparent;
&::-webkit-scrollbar { height: 6px; background: transparent; }
&::-webkit-scrollbar-thumb { background: hsla(220, 4%, 58%, .3); }
&::-webkit-scrollbar-track-piece {
background-color: transparent;
}
}
分段滚动
<!DOCTYPE html>
<html>
<head>
<style>
.scroll-container {
height: 100vh;
overflow-y: scroll;
scroll-snap-type: y mandatory;
}
.section {
height: 100vh;
scroll-snap-align: start;
border: 1px dashed #ccc;
}
</style>
</head>
<body>
<div class="scroll-container">
<div class="section">第一段内容</div>
<div class="section">第二段内容</div>
<div class="section">第三段内容</div>
</div>
</body>
</html>