html5图片自动滑动,怎样实现H5+CSS3手指滑动切换图片的示例代码

包含3个文件:html、slider-H5.js、jquery.js。在html中可配置滑动参数。具体代码如下:

HTML代码:

/>

H5手指滑动切换图片

ul,li{margin:0;padding:0;} @media screen and (min-width:240px) { html,

body{ font-size:9px; } } @media screen and (min-width:320px) { html, body{

font-size:12px; } } @media screen and (min-width:480px) { html, body{ font-size:18px;

} } @media screen and (min-width:640px) { html, body{ font-size:24px; }

} @media screen and (min-width:960px) { html, body{ font-size:36px; } }

div.imgbox{width:25rem;height:16.5rem;overflow:hidden;margin:0 auto;} div.imgbox

ul{clear:both;width:75rem;display: inline-block;} div.imgbox ul li{float:left;width:25rem;height:16.5rem;overflow:hidden;text-align:center;}

div.imgbox ul li img{width:24rem;height:16.5rem;} #page{color:red;}

  • 6842d5bcd2076dd6b470ece6097e5fdf.png

  • 0b2d16ec8ec066bea9d69a02585137a2.png

  • 409bed58741fb8f8f6a5f149d16a9238.png

这里通过回调显示当前滚动到多少页:

0

(function() {

/*

注意:$.mggScrollImg返回的scrollImg对象上有

next,prev,go三个方法,可以实现外部对滚动索引的控制。

如:scrollImg.next();//会切换到下一张图片

scrollImg.go(0);//会切换到第一张图片

*/

var scrollImg = $.mggScrollImg('.imgbox ul', {

loop: true,

//循环切换

auto: true,

//自动切换

auto_wait_time: 3000,

//轮播间隔

scroll_time: 300,

//滚动时长

callback: function(ind) { //这里传过来的是索引值

$('#page').text(ind + 1);

}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值