简单html无缝向上滚动,jquery实现简单的无缝滚动

jquery实现简单的无缝滚动

*{ margin: 0px; padding: 0px;}

li{ list-style: none;}

.content{ width: 1020px; height:112px; overflow: hidden; border: #4e83c2 solid 1px; margin:50px auto; }

.content ul{ width: 1020px; height:100px;}

.content ul li{ float: left; width: 100px; height: 100px; border:#ccc solid 1px; display: block; margin: 5px;}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

function scroll(){

$(".content ul").animate({"margin-left":"-110px"},function(){

$(".content ul li:eq(0)").appendTo($(".content ul"))

$(".content ul").css({"margin-left":0})

})

}

setInterval(scroll,1000)

scroll()用法:

function scroll(){

$(".content ul").animate({"margin-left":"-110px"},function(){

//这个是让整个ul先向前滑动个li ,如果要一次性滑动5个~那么就是550px.

//想向上滚动就改成 $(".content ul").animate({"margin-top":"-105px"}

//想向下滚动就改成 $(".content ul").animate({"margin-top":"105px"}

//想向右滚动就改成 $(".content ul").animate({"margin-left":"110px"}

$(".content ul li:eq(0)").appendTo($(".content ul"))

$(".content ul").css({"margin-left":0})

//对应这的这边

//想向上滚动就改成 $(".content ul").animate({"margin-top":0}

//想向下滚动就改成 $(".content ul").animate({"margin-top":0}

//想向右滚动就改成 $(".content ul").animate({"margin-left":0}

})

}

setInterval(scroll,1000)

//这上面的是1000是滚动的速度,可以自己调整

以上所述就是本文的全部内容了,希望大家能够喜欢。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值