纯js轮播
来源:互联网 发布:喜马拉雅 知乎 编辑:程序博客网 时间:2024/05/20 23:02
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>轮播</title> <style> *{margin: 0; padding:0;} .wrap{ position: relative; width: 500px; height: 200px; background: #ccc; margin:20px auto; } .pics,.pics li,.pics li img{ width: 100%; height: 100%; } .pics li{ position: absolute; } .btn{ position: absolute; top:70px; height: 60px; width: 40px; background: rgba(0,0,0,0.5); color: #fff; text-align: center; line-height: 60px; font-size: 30px; font-weight: lighter; cursor: pointer; z-index: 2; } .btn:hover{ background:rgba(0,0,0,0.8); } .btnr{ right: 0; } ul{list-style:none;} .pots{ position: absolute; left:166px; bottom: 10px; } .pots div{ width: 20px; height: 20px; background-color: #5388e8; float: left; text-align: center; line-height: 20px; color: #fff; margin-right: 5px; border-radius: 50%; cursor: pointer; } .pots div.active{background-color: #ff0000;} </style></head><body><div class="wrap"> <ul class="pics"> <li><img src="img/1.png" alt=""></li> <li><img src="img/2.png" alt=""></li> <li><img src="img/3.png" alt=""></li> <li><img src="img/4.png" alt=""></li> <li><img src="img/5.png" alt=""></li> <li><img src="img/6.png" alt=""></li> <li><img src="img/0.png" alt=""></li> </ul> <div class="pots"> <div class="active">1</div> <div>2</div> <div>3</div> <div>4</div> <div>5</div> <div>6</div> <div>7</div> </div> <div class="btn btnl"><</div> <div class="btn btnr">></div></div><script src="jquery-1.4.2.min.js"></script><script>var $li=$(".pics li");var count=0;var timer;$(function(){ $li.eq(0).show().siblings().hide(); ShowTime(); $(".pots div").hover(function(){ clearInterval(timer); count = $(this).index(); Show(); },function(){ ShowTime(); }); $(".btnl").click(function(){ clearInterval(timer); count--; if(count == -1){ count = $li.length; } Show(); }); $(".btnr").click(function(){ clearInterval(timer); count++; if(count == $li.length){ count = 0; } Show(); });});function Show(){ $li.eq(count).fadeIn(300).siblings().hide(); $(".pots div").eq(count).addClass("active").siblings().removeClass("active");}function ShowTime(){ timer = setInterval(function(){ count++; Show(); },2000);}</script></body></html>
阅读全文
0 0
- 纯js轮播
- 纯js 手写轮播
- 纯原生JS轮播图片
- 纯js制作图片轮播效果
- 图片轮播--纯css
- 纯css3实现图片轮播
- 纯css实现轮播效果
- 纯CSS实现图片轮播
- 浅谈纯CSS实现轮播
- 纯css实现幻灯片轮播效果
- js图片轮播
- js图片轮播
- js图片轮播
- JS 图片轮播
- js图片轮播
- js图片轮播
- js 轮播
- unslider.js轮播
- js中字符串的方法(上)
- 逻辑回归(Logistic Regression)
- 表示数值的字符串(字符串)
- 单点登录(二)----实战------简单搭建CAS---测试认证方式搭建CAS
- spring使用aop时需要设置proxy-target-class="true" 否则无法依赖注入
- 纯js轮播
- suoj20 垃圾显示屏(cdq分治+树状数组)
- 《转行机器学习》二、Logistic Regression及其实现
- linux大量小文件复制
- 自顶向下逐步求精
- instr函数
- 运用EasyUI 进行输入框数据检索
- 18 i2c控制器之应用程序的调用
- mysql的几种常见的模糊查询