<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>mbb</title>
<style>
*{
margin: 0;
padding: 0;
list-style: none;
}
img{
width: 500px;
position: absolute;
width: 500px;
height: 231px;
border: solid 2px red;
overflow: hidden;
position: absolute;
width: 2500px;
left: -2000px
}
.show>.xulie>li{
float: right;
position: absolute;
z-index: 1;
left: 180px;
top: 210px;
height: 5px;
width: 5px;
float: left;
margin-left: 20px;
background-color: red;
cursor: pointer;
background-color: black;
}
</style>
<script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script>
var cur_num=0;
var timer=0;
window.num=0;
timer=setInterval(function(){
num++;
if(num>4){
num=0
var cur_num=$(this).index();
num=cur_num;
$('.xulie').css('left',-(2000-(num*500))+'px');
$('.sec ul li').eq(cur_num).addClass('current').siblings('li').removeClass('current');
})
});
</script>
</head>
<body>
<div class="show">
<li><img src="images/02.jpg" alt=""></li>
<li><img src="images/03.jpg" alt=""></li>
<li><img src="images/04.jpg" alt=""></li>
<li><img src="images/05.jpg" alt=""></li>
</ul>
//点击实现跳转
</div>
<div class="sec">
<ul>
<li class="current"></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>mbb</title>
<style>
*{
margin: 0;
padding: 0;
list-style: none;
}
img{
width: 500px;
}
/*ul移动必须有position属性*/
position: absolute;
width: 500px;
height: 231px;
border: solid 2px red;
overflow: hidden;
}
/*初始定位*/
position: absolute;
width: 2500px;
left: -2000px
}
.show>.xulie>li{
float: right;
}
/*z-index表示显示优先*/
position: absolute;
z-index: 1;
left: 180px;
top: 210px;
}
/*将li变形*/
height: 5px;
width: 5px;
float: left;
margin-left: 20px;
background-color: red;
cursor: pointer;
}
/*点击后添加样式*/
background-color: black;
}
</style>
<script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
//图片轮播 原理:设定一个div,ul的图片在里面进行位移,overflow为hidden
var cur_num=0;
var timer=0;
window.num=0;
timer=setInterval(function(){
num++;
if(num>4){
num=0
}
//点击变换颜色
$('.sec ul li').eq(num).addClass('current').siblings('li').removeClass('current');
//往右边位移
},2000);
//点击跳转
var cur_num=$(this).index();
num=cur_num;
$('.xulie').css('left',-(2000-(num*500))+'px');
$('.sec ul li').eq(cur_num).addClass('current').siblings('li').removeClass('current');
})
});
</script>
</head>
<body>
<div class="show">
<ul class="xulie">
//我的图片,读者自己替换成自己的图片
<li><img src="images/02.jpg" alt=""></li>
<li><img src="images/03.jpg" alt=""></li>
<li><img src="images/04.jpg" alt=""></li>
<li><img src="images/05.jpg" alt=""></li>
</ul>
//点击实现跳转
</div>
<div class="sec">
<ul>
<li class="current"></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</body>
</html>