Bootstrap:在轮播的一个项目中的多个图像中只滑动一个图像 [英] Bootstrap: Slide only one image among the multiple images in an item of the carousel
问题描述
我正在实施 Bootstrap Carousel,以便在每个轮播项目中查看多个图像缩略图(4 个图像).当我点击下一个或上一个控件时,它应该只从 4 个图像中滑出 1 个图像.我该如何实现这一点.
我已经尝试过这个例子 skelly 建议 但是当我实施它时它只在轮播,当我单击上一个/下一个控件时,除了较早的一个图像外,只显示了一个图像.我需要一直显示四张图像.如果左侧的 1 个图像消失,则同时应从右侧插入另外 1 个图像.我另外添加了jquery/1.11.1/jquery.min.js"和bootstrap-3.2.0-dist/bootstrap.js",但没有用.
我实现的代码如下:
<头><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><script src="./bootstrap-3.2.0-dist/js/bootstrap.js"></script><script type="text/javascript">$('#myCarousel').carousel({间隔:4000})$('.carousel .item').each(function(){var next = $(this).next();如果(!下一个.长度){next = $(this).siblings(':first');}next.children(':first-child').clone().appendTo($(this));for (var i=0;i<2;i++) {next=next.next();如果(!下一个.长度){next = $(this).siblings(':first');}next.children(':first-child').clone().appendTo($(this));}});<style type="text/css">.carousel-inner .active.left { 左:-25%;}.carousel-inner .next { left: 25%;}.carousel-inner .prev { 左:-25%;}.carousel-control { 宽度:4%;}.carousel-control.left,.carousel-control.right {margin-left:15px;background-image:none;}</风格>头部><身体><div class="col-md-12 text-center"><h3>Bootstrap 3 Multiple Slide Carousel</h3></div><div class="col-md-6 col-md-offset-3"><div class="carousel slide" id="myCarousel"><div class="carousel-inner"><div class="item active"><div class="col-xs-3"><a href="#"><img src="http://placehold.it/500/e499e4/fff&text=1"class="img-responsive"></a></div>
<div class="item"><div class="col-xs-3"><a href="#"><img src="http://placehold.it/500/e477e4/fff&text=2"class="img-responsive"></a></div>
<div class="item"><div class="col-xs-3"><a href="#"><img src="http://placehold.it/500/eeeeee&text=3" class=img-responsive"></a></div>
<div class="item"><div class="col-xs-3"><a href="#"><img src="http://placehold.it/500/f4f4f4&text=4" class=img-responsive"></a></div>