如何使用bootstrap 3将轮播项目导航为一组?我们不是一次只移动一个项目,而是如何通过点击移动多个项目。对于例如如果我看到幻灯片1,2,3,则下一个轮播控件应显示幻灯片4,5,6。
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="item active">
<div class="col-xs-3"><a href="#"><img src="images\link4\Picture1.png" class="img-responsive"></a></div>
</div>
<div class="item">
<div class="col-xs-3"><a href="#"><img src="images\link4\Picture2.png" class="img-responsive"></a></div>
</div>
<div class="item">
<div class="col-xs-3"><a href="#"><img src="images\link4\Picture3.png" class="img-responsive"></a></div>
</div>
<div class="item">
<div class="col-xs-3"><a href="#"><img src="images\link4\Picture4.png" class="img-responsive"></a></div>
</div>
<div class="item">
<div class="col-xs-3"><a href="#"><img src="images\link4\Picture5.png" class="img-responsive"></a></div>
</div>
<div class="item">
<div class="col-xs-3"><a href="#"><img src="images\link4\Picture2.png" class="img-responsive"></a></div>
</div>
<div class="item">
<div class="col-xs-3"><a href="#"><img src="images\link4\Picture4.png" class="img-responsive"></a></div>
</div>
<div class="item">
<div class="col-xs-3"><a href="#"><img src="images\link4\Picture3.png" class="img-responsive"></a></div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<script>
$('.carousel .item').each(function(){
var next = $(this).next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
for (var i=0;i<2;i++) {
next = next.next();
if (next.length>0) {
next.children(':first-child').clone().appendTo($(this));
}
else {
$(this).siblings(':first').children(':first-child').clone().appendTo($(this));
} }
});
</script>
答案 0 :(得分:0)
不需要额外的JS。只需使用标准的Bootstrap轮播......
<div class="carousel-inner">
<div class="item active">
<div class="col-xs-3">
<a href="#"><img src="//placehold.it/400" class="img-responsive"></a>
</div>
<div class="col-xs-3">
<a href="#"><img src="//placehold.it/400" class="img-responsive"></a>
</div>
<div class="col-xs-3">
<a href="#"><img src="//placehold.it/400" class="img-responsive"></a>
</div>
<div class="col-xs-3">
<a href="#"><img src="//placehold.it/400" class="img-responsive"></a>
</div>
</div>
<div class="item">
<div class="col-xs-3">
<a href="#"><img src="//placehold.it/400" class="img-responsive"></a>
</div>
<div class="col-xs-3">
<a href="#"><img src="//placehold.it/400" class="img-responsive"></a>
</div>
<div class="col-xs-3">
<a href="#"><img src="//placehold.it/400" class="img-responsive"></a>
</div>
<div class="col-xs-3">
<a href="#"><img src="//placehold.it/400" class="img-responsive"></a>
</div>
</div>
</div>