轮播图(使用jq插件)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/jquery.caroufredsel/6.1.0/jquery.carouFredSel.packed.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$('#carousel').carouFredSel({
width: '100%',
items: {
visible: 'odd+2'
},
scroll: {
pauseOnHover: true,
onBefore: function() {
$(this).children().removeClass( 'hover' );
}
},
auto: {
items: 1,
easing: 'linear',
duration: 1250, //调节速度
timeoutDuration: 0 //停顿时间
},
pagination: {
container: '#pager',
items: 1,
duration: 0.5,
queue: 'last',
onAfter: function() {
var cur = $(this).triggerHandler( 'currentVisible' ),
mid = Math.floor( cur.length / 2 );
cur.eq( mid ).addClass( 'hover' );
}
}
});
});
</script>
<style type="text/css">
#wrapper {
width: 380px;
}
#carousel {
margin-top: -60px;
}
#carousel div {
text-align: center;
width: 385px;
height: 300px;
padding: 0 20px;
float: left;
position: relative;
}
#carousel div img {
border: none;
width:385px;
height: 300px;
}
#carousel div span {
display: none;
}
#carousel div:hover span,
#carousel div.hover span {
background-color: #333;
color: #fff;
display: inline-block;
width: 100px;
padding: 2px 0;
margin: 0 0 0 -50px;
position: absolute;
bottom: 0;
left: 50%;
border-radius: 3px;
}
#pager {
text-align: center;
padding-top: 20px;
}
#pager a {
background: #ccc;
display: inline-block;
border-radius: 5px;
width: 10px;
height: 10px;
margin: 0 2px;
}
#pager a.selected {
background: #999;
}
#pager a:hover {
background: #666;
}
#pager a span {
display: none;
}
#donate-spacer {
height: 100%;
}
#donate {
width: 750px;
padding: 50px 75px;
margin: 0 auto;
overflow: hidden;
}
#donate p, #donate form {
margin: 0;
float: left;
}
#donate p {
width: 650px;
}
#donate form {
width: 100px;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="carousel">
<div>
<img src="img/1.png" alt="fruit1" width="200" height="200" />
<span>Apple</span>
</div>
<div>
<img src="img/2.png" alt="fruit2" width="200" height="200" />
<span>Mandarin</span>
</div>
<div>
<img src="img/3.png" alt="fruit3" width="200" height="200" />
<span>Banannas</span>
</div>
<div>
<img src="img/4.png" alt="fruit4" width="200" height="200" />
<span>Cherries</span>
</div>
<div>
<img src="img/5.png" alt="fruit5" width="200" height="200" />
<span>Orange</span>
</div>
<div>
<img src="img/6.png" alt="fruit6" width="200" height="200" />
<span>Melon</span>
</div>
<div>
<img src="img/7.png" alt="fruit7" width="200" height="200" />
<span>Lemon</span>
</div>
<div>
<img src="img/8.png" alt="fruit8" width="200" height="200" />
<span>Grapes</span>
</div>
<div>
<img src="img/9.png" alt="fruit9" width="200" height="200" />
<span>Peach</span>
</div>
<div>
<img src="img/10.png" alt="fruit10" width="200" height="200" />
<span>Pear</span>
</div>
<div>
<img src="img/11.png" alt="fruit11" width="200" height="200" />
<span>Strawberry</span>
</div>
<div>
<img src="img/12.png" alt="fruit12" width="200" height="200" />
<span>Melon</span>
</div>
</div>
</div>
</body>
</html>