首页 > 其他 > 详细

简单的点击轮播图效果

时间:2017-04-18 13:07:41      阅读:317      评论:0      收藏:0      [点我收藏+]

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
ul{
list-style: none;
}
#box{
width: 500px;
border: 1px solid red;
margin: 40px auto;
overflow: hidden;
position: relative;
height: 300px;
}
#list{
width: 2500px;
height: 300px;
border: 1px solid blue;
position: absolute;
}
#list li img{
float: left;
width: 500px;
height: 300px;
text-align: center;
line-height: 300px;
font-size: 40px;
}
#list2{
width: 120px;
position: absolute;right: 180px;bottom: 10px;
z-index: 999;
}
#list2 li{
width: 18px;
height: 20px;
background: red;
border-radius: 40%;
float: left;
margin: 2px;
cursor: pointer;
}
</style>
<script src="common.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
window.onload = function(){
var oList = $(‘list‘),
oList2= $(‘list2‘),
oLi = oList2.children,
oTimer=null,
//oFirst= oList.firstElementChild,
iIndex=0;


for(let i=0;i<oLi.length;i++){
oLi[i].onmouseover = function(){
clearInterval(oTimer);
oList.style.left=i*(-500)+‘px‘;
//oLi[iIndex].style.backgroundColor = "#f00";
};
oLi[i].onmouseleave = function(){
oTimer=setInterval(function(){
if(iIndex ===5){
iIndex=0;
oList.style.left=0;
}
bufferMove(oList,{left:-500*iIndex});
iIndex++;
},2000)
}
};
//oList.innerHTML += oFirst.outerHTML;
//for(var i=0;i<oLi.length;i++){

oTimer=setInterval(function(){
if(iIndex ===5){
iIndex=0;
oList.style.left=0;
}
bufferMove(oList,{left:-500*iIndex});
iIndex++;
},2000)
//}

}
</script>
</head>
<body>
<div id="box">
<ul id="list">
<li>
<img src="img/1.jpg"/>
</li>
<li>
<img src="img/2.jpg"/>
</li>
<li>
<img src="img/3.jpg"/>
</li>
<li>
<img src="img/4.jpg"/>
</li>
<li>
<img src="img/5.jpg"/>
</li>
</ul>
<ul id="list2">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</body>
</html>

简单的点击轮播图效果

原文:http://www.cnblogs.com/xcbk/p/6726932.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!