<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<body>
<div class="container">
<div class="row">
<div class="col-md-8">
<div id="carouselMenu" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#carouselMenu" data-slide-to="0" class="active"></li>
<li data-target="#carouselMenu" data-slide-to="1"></li>
<li data-target="#carouselMenu" data-slide-to="2"></li>
<li data-target="#carouselMenu" data-slide-to="3"></li>
<li data-target="#carouselMenu" data-slide-to="4"></li>
<li data-target="#carouselMenu" data-slide-to="5"></li>
<li data-target="#carouselMenu" data-slide-to="6"></li>
<li data-target="#carouselMenu" data-slide-to="7"></li>
<li data-target="#carouselMenu" data-slide-to="8"></li>
</ol>
<div class="carousel-inner">
<div class="item active"><img src="http://placehold.it/800x300" alt="" /></div>
<div class="item"><img src="http://placehold.it/800x300" alt="" /></div>
<div class="item"><img src="http://placehold.it/800x300" alt="" /></div>
<div class="item"><img src="http://placehold.it/800x300" alt="" /></div>
<div class="item"><img src="http://placehold.it/800x300" alt="" /></div>
<div class="item"><img src="http://placehold.it/800x300" alt="" /></div>
<div class="item"><img src="http://placehold.it/800x300" alt="" /></div>
<div class="item"><img src="http://placehold.it/800x300" alt="" /></div>
<div class="item"><img src="http://placehold.it/800x300" alt="" /></div>
</div>
<a class="carousel-control left" href="#carouselMenu" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="carousel-control right" href="#carouselMenu" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
/*
* interval为每个轮播项之间的切换时间
* wrap定义是否循环轮播
*
* */
$("#carouselMenu").carousel({
interval: 3000,
wrap: true
});
})
</script>
</body>
</html>
附录:向前或者向后滚动结合jquery实现 ,(此上为纯bootstrap)
<a class="carousel-control left" href="javascript:$('.carousel').carousel('prev')" >
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="carousel-control left" href="javascript:$('.carousel').carousel('next')" >
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
网友评论