公告栏上下滚动效果

Gella ·
更新时间:2024-09-21
· 548 次阅读

公告栏上下滚动效果 公告栏上下滚动 body { background: grey; } ul,li{list-style: none;padding: 0;margin: 0;} .Roll { padding: 0; text-align: left; text-indent: 10px; cursor: pointer; opacity: 1; height: 6rem; line-height: 3rem; font-size: 17px; background-color: #fff; color: #fe172d; } .ul li { background-color: #A6E1EC; border-radius: 20px; height: 2rem; margin: 50px auto; opacity: 0; line-height: 2rem; }
  • 11111刚刚购买了一单
  • 22222刚刚购买了一单
  • 33333刚刚购买了一单
  • 44444刚刚购买了一单
  • 55555刚刚购买了一单
  • 66666刚刚购买了一单
statr = () => { //创造一个循环方法函数 let first = $('.ul li:first'), //获取列表第一个li firstLi = first.clone(); //复制第一个li $('.ul li').eq(0).animate({ //列表第一个添加动画, marginTop: '-=15px', opacity: '1' }, 2000) setTimeout(function() { $('.ul li').eq(0).animate({//列表第二个添加动画, marginTop: '-=15px', opacity: '0' }, 2000); setTimeout(function() {//动画结束后删除第一个li first.remove(); }, 2000) $('.ul').append(firstLi)//li复制到最后面开始新的一轮循环 },4000) } setInterval('statr()', 7000) //7秒循环一次

作者:小黑2635121987



公告栏 动效

需要 登录 后方可回复, 如果你还没有账号请 注册新账号