包含3个文件:html、slider-H5.js、jquery.js。在html中可配置滑动参数。具体代码如下:
HTML代码:
<!DOCTYPE HTML>
<html> <head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, target-densitydpi=high-dpi, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta content="telephone=no" name="format-detection" />
<meta name="keywords" content="seokeywords" />
<meta name="description" content="seodescription" />
<title>
H5手指滑动切换图片
</title>
<style>
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;}
</style>
</head>
<body>
<div class="imgbox">
<ul>
<li>
<a href="#">
<img src="http://huoche.7234.cn/images/jb51/3jes4wp132j.jpg">
</img>
</a>
</li>
<li>
<a href="#">
<img src="http://huoche.7234.cn/images/jb51/nqnh2doqn1p.jpg">
</img>
</a>
</li>
<li>
<a href="#">
<img src="http://huoche.7234.cn/images/jb51/gbc040fpoz1.jpg">
</img>
</a>
</li>
</ul>
</div>
<div>
这里通过回调显示当前滚动到多少页:
<span id="page">
0
</span>
</div>
<script src="jquery-1.10.2yuan.js">
</script>
<script src="slider-H5.js">
</script>
<script>
(function() {
/*
注意:$.mggScrollImg返回的scrollImg对象上有
next,prev,go三个方法,可以实现外部对滚动索引的控制。
如:scrollImg.next();//会切换到下一张图片
scrollImg.go(0);//会切换到第一张图片









