vue或css动画实现列表向上无缝滚动
vue或css动画实现列表向上无缝滚动
html
<div class="b_list">
<div class="b_scroll">
<div class="b_item" v-for="(ac,acindex) in activityList" :key="acindex">
<!-- 循环的内容 -->
</div>
</div>
</div>
css:使用纯css动画实现数据向上滚动
@keyframes scrollTop {
0% {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
100% {
-webkit-transform: translate3d(0, -300px, 0);
transform: translate3d(0, -300px, 0);
}
}
.b_list{
height: 19rem;
overflow: hidden;
}
.b_scroll{
-webkit-animation: 10s scrollTop linear infinite normal;
animation: 10s scrollTop linear infinite normal;
}
二、使用scrollTop方法向上滚动
scrolltolowerOne() {
this.breakfastScrollInterval = setInterval(() => {
let div = document.getElementById('breakfastList');
if (div) {
if (div.scrollTop + div.offsetHeight >= div.scrollHeight) {
this.breakfastScrollTop = 0;
} else {
this.breakfastScrollTop += 1;
}
div.scrollTop = this.breakfastScrollTop;
} else {
clearInterval(this.breakfastScrollInterval);
this.breakfastScrollInterval = null;
}
}, 50)
},
更多推荐
所有评论(0)