解决方式:
父元素:overflow:hidden,并设置高度
子元素:overflow:auto,padding-bottom设置超过父元素高度
使得滚动条往下移动,利用父元素的overflow:hidden隐藏滚动条
例子:
html
<div class="num">
<div class="number">
<span class= "index" v-for=" item in 19" :key="item" >{{item}}</span>
</div>
</div>
css:
.num{
margin-top: 200px;
height: 30px;
overflow: hidden;
}
.number{
white-space: nowrap;
overflow: auto;
padding-bottom: 60px;
}
.index{
display: inline-block;
background: rgb(189, 100, 100);
width: 30px;
height: 30px;
line-height: 30px;
text-align: center;
margin-right: 10px;
}