我通过在CSS 中添加以下内容来隐藏垂直滚动条
overflow: hidden;
然后在不显示滚动条的情况下继续享受滚动,我键入以下代码:
overflow-y: scroll;
scroll-snap-type: y mandatory;
当然,滚动条会重新出现,滚动条也会正常工作。
我想隐藏滚动条,但我做不到。我试了很多把戏都没成功。
谢谢你启发我。
使用::-webkit-scrollbar
。
::-webkit-scrollbar {
opacity: 0;
width: 0;
display: none;
background-color: transparent;
}
.div1 {
height: 200vh;
background-color: green;
}
.div2 {
height: 100px;
background-color: red;
}
<div class="div1">
scroll me
</div>
<div class="div2"></div>