目的: 使用jQuery实现一个轮播图。鼠标单机左右箭头实现切换上/下一章。三秒自动轮播一张图片,鼠标悬停停止自动切换,鼠标离开继续实现三秒自动切换,并且图片下面的小圆点跟随图片切换。
代码示例如下:
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
text-decoration: none;
}
img{
width: 600px;
height: 400px;
float: left;
}
.container{
width: 600px;
height: 400px;
margin: 50px auto;
position: relative;
overflow: hidden;
}
.imgs{
width: 4200px; /* 7张图片的宽 7*600=4200 */
height: 400px;
position: absolute;
left: 0px;/* 轮播图控制的就是绝对定位的left */
overflow: hidden;
}
.point{
width: 100px;
height: 10px;
position: absolute;
left: 250px;
bottom: 20px;
}
.point span{
display: block;
width: 10px;
height: 10px;
background: #333;
border-radius: 50%;
border:1px solid #FFF;
float: left;
margin-right: 10px;
cursor: pointer;
}
.point span.on{
background-color: orange;
}
.arrow{
width: 40px;
height: 40px;
font-size: 36px;
line-height: 35px;
cursor: pointer;
position: absolute