jquery多张单图自动轮播
来源:互联网 发布:哪个软件可以买双色球 编辑:程序博客网 时间:2024/06/07 14:13
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <meta name="renderer" content="webkit|ie-comp|ie-stand"> <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no"> <meta name="format-detection" content="telephone=no" /> <title>单图轮播</title> <style> * { margin: 0; padding: 0; border: none; box-sizing: border-box; } ul li { list-style: none; } a { text-decoration: none; } .clear { clear: both; overflow: hidden; } .lunboBox { width: 232px; height: 225px; position: relative; margin: 20px auto; } .lunbo { width: 176px; overflow: hidden; height: 225px; margin: 0 auto; position: relative; } .lunbo ul { width: 538px; position: absolute; top: 0; } .lunbo ul li { float: left; width: 176px; } .lunBo_img { width: 110px; height: 161px; margin: 0 auto; } .lunBo_img img { display: inline-block; width: 110px; height: 161px; } .lunboBox a.leftArrow, .lunboBox a.rightArrow { cursor: pointer; display: inline-block; width: 23px; height: 37px; position: absolute; top: 64px; } .leftArrow { left: 0; } .rightArrow { right: 0; } </style> </head> <body> <div class="lunboBox"> <a class="leftArrow"> <img src="images/left_arrow.png"> </a> <div class="lunbo"> <ul class="clear"> <li> <div class="lunBo_img"> <a href="" class="lunboTitle"> <img src="images/3-1.jpg" onerror=""> </a> </div> </li> <li> <div class="lunBo_img"> <a href="" class="lunboTitle"> <img src="images/3-2.jpg" onerror=""> </a> </div> </li> <li> <div class="lunBo_img"> <a href="" class="lunboTitle"> <img src="images/3-3.jpg" onerror=""> </a> </div> </li> </ul> </div> <a class="rightArrow"> <img src="images/right_arow.png"> </a> </div> <script src="http://libs.baidu.com/jquery/1.5.2/jquery.min.js"></script> <script> // 单图轮播js var currentPositon = 0, // 点击之后要跳转的位置 currentPage = 0, // 点击之后要跳转到的页面(0, 1, 2) imgLength = $('.lunBo_img img').length, // 轮播图片数量 step = $(".lunbo ul li").width(); // 移动的距离 isClick = 0; // 是否点击箭头进行跳转 // 点击左箭头 $(".leftArrow").click(function () { currentPage--; isClick = 1; if(currentPage < 0) { currentPage = imgLength - 1; //移动到最后一张 currentPositon = -step * (imgLength - 1); } else { currentPositon += step; } //清除定时器 clearInterval(autoPlay); changeTo(currentPositon); }); // 点击右箭头 $(".rightArrow").click(function () { currentPage++; isClick = 1; if(currentPage > imgLength - 1) { currentPage = 0; //移动到第一张 currentPositon = 0; } else { currentPositon += -step; } //清除定时器 clearInterval(autoPlay); changeTo(currentPositon); }); //移动位置 function changeTo(position) { $(".lunbo ul").animate({ left: position + "px" }, 500, function() { console.log('进来了') }) //如果当前是点击,则继续自动播放 if(isClick == 1) { isClick = 0; autoPalyAgain(); } } // 定时器自动变换3秒每次 var autoPlay = setInterval(function() { currentPage++; if(currentPage > imgLength - 1) { currentPage = 0; currentPositon = 0; } else { currentPositon += -step; } changeTo(currentPositon); }, 3000); //再次自动播放 function autoPalyAgain() { autoPlay = setInterval(function() { currentPage++; if(currentPage > imgLength - 1) { currentPage = 0; currentPositon = 0; } else { currentPositon += -step; } changeTo(currentPositon); }, 3000); } </script> </body></html>
阅读全文
1 0
- jquery多张单图自动轮播
- jquery图片自动轮播效果
- jquery实现图片自动轮播
- 使用jQuery实现图片自动轮播
- jquery聚焦自动轮播图片
- 自动轮播图
- 自动轮播
- 自动轮播条
- 自动轮播
- ViewPager自动轮播
- 自动轮播
- 自动轮播
- viewpage自动轮播
- ViewPager自动轮播
- 自动轮播
- Banner自动轮播
- viewpager自动轮播
- 图片自动轮播
- 理解Javascript中的事件绑定与事件委托
- mac 安装 cmake boost kenlm
- WebService的几个知识点
- 0x0139B9处有未经处理的异常 0xc0000FD:Stack overflow
- python strip()函数 删除字符串中无空白字符或者是无用字符
- jquery多张单图自动轮播
- Mac OSX Docker下搭建Android+Jenkins+Gitlab
- vijos1698单轨纵帆船
- caffe(二): 利用训练好的MNIST模型测试自己的手写字符图片
- Error:Configuration with name 'default' not found. 解决办法
- 七月突然的决定
- 支付开发所需配置信息
- LVS负载均衡+keepalived高可用+Nginx反向代理+Session共存
- 转载