java延时轮播图_[Java教程]焦点轮播图效果_星空网

焦点轮播图效果

2017-06-03

0

焦点轮播图效果

*{

margin: 0;

padding: 0;

list-style-type: none;

}

.wrap{

width:490px;

height: 170px;

margin: 100px auto;

overflow: hidden;

position: relative;

}

.wrap ul{

position: absolute;

}

.wrap li{

height: 170px;

}

.list{

position: absolute;

right: 10px;

bottom: 10px;

}

.list li{

float: left;

width: 20px;

height: 20px;

background-color: #ccc;

border: 1px solid #666;

margin-left: 5px;

color: #000;

text-align: center;

line-height: 20px;

cursor: pointer;

}

.list li.on{

background-color: #E57000;

color: #fff;

}

  • 图1
  • 图2
  • 图3
  • 图4
  • 图5
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5

window.οnlοad=function () {

//获取元素,申明变量

var wrap=document.getElementById('wrap'),

pic=document.getElementById('pic'),

list=document.getElementById('list').getElementsByTagName('li');

var index=0,

that=this,

timer=null;

//绑定

function autoPlay(){

index++;

if (index>=list.length) {

index=0;

}

qiehuan(index);

}

timer=setInterval(autoPlay,2000);

//鼠标滑过整个容器时停止切换(定时器)

wrap.οnmοuseοver=function(){

clearInterval(timer)

}

//鼠标离开时,继续切换

wrap.οnmοuseοut=function(){

timer=setInterval(autoPlay,2000);

}

//遍历所有数字导航,实现滑过切换至对应得图片

for (var j = 0; j < list.length; j++) {

list[j].id=j;

list[j].οnmοuseοver=function(){

qiehuan(this.id);

clearInterval(timer);

}

}

function qiehuan(num){

for (var i = 0; i < list.length; i++) {

list[i].className="";

}

list[num].className="on";

pic.style.top="-"+num*170+"px";

num=index;

}

}

0

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:admin@shaoqun.com。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值