自己所做的一个轮播图案例,以供参考,欢迎指教
2018-06-24 00:59:28来源:未知 阅读 ()
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <link rel="stylesheet" href="css/common.css"/> <link rel="stylesheet" href="css/index.css"/> <script src="js/common.js"></script> </head> <body> <div class="pictures" id="pic"> <ul> <li><a href="javascript:void(0);"><img src="images/33.jpg" alt=""/></a></li> <li><a href="javascript:void(0);"><img src="images/22.jpg" alt=""/></a></li> <li><a href="javascript:void(0);"><img src="images/11.jpg" alt=""/></a></li> <li><a href="javascript:void(0);"><img src="images/55.jpg" alt=""/></a></li> <li><a href="javascript:void(0);"><img src="images/44.jpg" alt=""/></a></li> <li><a href="javascript:void(0);"><img src="images/33.jpg" alt=""/></a></li> <li><a href="javascript:void(0);"><img src="images/22.jpg" alt=""/></a></li> <li><a href="javascript:void(0);"><img src="images/11.jpg" alt=""/></a></li> <li><a href="javascript:void(0);"><img src="images/55.jpg" alt=""/></a></li> <li><a href="javascript:void(0);"><img src="images/44.jpg" alt=""/></a></li> </ul> <ol> <li><a href="javascript:void(0);"><img src="images/1.jpg" alt=""/></a></li> <li><a href="javascript:void(0);"><img src="images/2.jpg" alt=""/></a></li> <li><a href="javascript:void(0);"><img src="images/3.jpg" alt=""/></a></li> <li><a href="javascript:void(0);"><img src="images/4.jpg" alt=""/></a></li> <li><a href="javascript:void(0);"><img src="images/5.jpg" alt=""/></a></li> <li><a href="javascript:void(0);"><img src="images/1.jpg" alt=""/></a></li> </ol> </div> </body> <script> //图片库开始 window.onload = function () { var config = [ { "top": 0, "left": 0, "opacity": 0.3, "zIndex": 1 },//0 { "top": 120, "left": 100, "opacity": 0.5, "zIndex": 2 },//1 { //"width": 200, "top": 240, "left": 200, "opacity": 1, "zIndex": 3 },//2 { //"width": 150, "top": 320, "left": 100, "opacity": 0.5, "zIndex": 2 },//3 { //"width": 100, "top": 407, "left": 0, "opacity": 0.3, "zIndex": 1 },//4 { //"height":100, //"width": 100, "top": 407, "left": -200, "opacity": 0.3, "zIndex": 1 },//5 { //"width": 150, "top": 320, "left": -300, "opacity": 0.5, "zIndex": 2 },//6 { //"width": 200, "top": 240, "left": -400, "opacity": 1, "zIndex": 3 },//7 { //"width": 150, "top": 120, "left": -300, "opacity": 0.5, "zIndex": 2 },//8 { //"width": 100, "top": 0, "left": -200, "opacity": 0.3, "zIndex": 1 },//9 ]; var pictures = document.getElementById("pic"); var ul = pictures.children[0]; var ulLis = ul.children; var ol = pictures.children[1]; var olLis = ol.children; function assign() { for (var i = 0; i < ulLis.length; i++) { animate(ulLis[i], config[i]); flag = true; } } assign(); var imgWidth = olLis[0].offsetWidth; var index = 0; var timer1 = null; var timer2 = null; timer1 = setInterval(function () { config.push(config.shift()); //indexNum++; //console.log(indexNum); for (var i = 0; i < ulLis.length; i++) { animate(ulLis[i], config[i]); } index++; if (index == 6) { ol.style.left = 0; index = 1; } }, 4000); timer2 = setInterval(function () { if (index < 6) { var target = -imgWidth * index; cutton(ol, target, 20); } }, 2000); for (var k = 0; k < ulLis.length; k++) { ulLis[k].onmouseover = function () { clearInterval(timer1); clearInterval(timer2); } ulLis[k].onmouseout = function () { timer1 = setInterval(function () { config.push(config.shift()); for (var i = 0; i < ulLis.length; i++) { animate(ulLis[i], config[i]); } index++; if (index == 6) { ol.style.left = 0; index = 1; } }, 4000); timer2 = setInterval(function () { if (index < 6) { var target = -imgWidth * index; cutton(ol, target, 20); } }, 2000); } } //var indexNum = 0; var flag = true; for (var num = 0; num < ulLis.length; num++) { ulLis[num].onclick = function () { if (flag) { flag = false; if (this.offsetTop == 0) { flag = true; config.push(config.shift()); config.push(config.shift()); assign(); index = index + 2; if (index == 6) { ol.style.left = 0; index = 1; } if (index < 6) { var target = -imgWidth * index; animate(ol, {left: target}); } console.log(index); }//1 if (this.offsetTop == 120) { flag = true; config.push(config.shift()); assign(); index = index + 1; if (index == 6) { ol.style.left = 0; index = 1; } if (index < 6) { var target = -imgWidth * index; animate(ol, {left: target}); } }//2 if (this.offsetTop == 320) { flag = true; //if (indexNum > 0) { config.unshift(config.pop()); assign(); index = index - 1; console.log(index); if (index < 0) { index = index + 5; } if (index == 6) { ol.style.left = 0; index = 1; } if (index < 6) { var target = -imgWidth * index; animate(ol, {left: target}); } //indexNum = indexNum - 1; // } }//4 if (this.offsetTop == 407) { flag = true; //if (indexNum > 1) { config.unshift(config.pop()); config.unshift(config.pop()); assign(); index = index - 2; if (index < 0) { index = index + 5; } if (index == 6) { ol.style.left = 0; index = 1; } if (index < 6) { var target = -imgWidth * index; animate(ol, {left: target}); } //indexNum = indexNum - 2; //} }//5 } } } } //图片库结束 </script> </html>
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:Framework7初始化
下一篇:CSS学习总结-盒子模型
- HTML基础01 2020-06-07
- 如何在博客园添加自己的头像 2020-05-27
- 想成为一个高薪WEB前端程序员,这些书籍你要看 2020-05-22
- 构建一个杂志布局(译文) 2020-05-14
- Emmet插件的使用 2020-04-27
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash