引导轮播是否可扩展以在滑块中显示下一个和上一个图像?
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel" data-interval="false"> <!-- Indicators --> <ol class="carousel-indicators"> <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li> <li data-target="#carousel-example-generic" data-slide-to="1"></li> </ol> <!-- Wrapper for slides --> <div class="carousel-inner"> <div class="item active"> <img src="img/bike.png" alt="..."> <div class="carousel-caption"> ... </div> </div> <div class="item"> <img src="img/bike2.png" alt="..."> <div class="carousel-caption"> ... </div> </div> </div> <!-- Controls --> <a class="left carousel-control" href="#carousel-example-generic" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left"></span> </a> <a class="right carousel-control" href="#carousel-example-generic" data-slide="next"> <span class="glyphicon glyphicon-chevron-right"></span> </a> </div>
目前,我的轮播看起来像这样,如何将上一张和下一张图像添加到当前活动的幻灯片中?
Bootstrap是可能的,但是需要一些自定义…
您必须使用CSS和jQuery自定义幻灯片的位置。
.carousel-inner .active.left { left: -33%; } .carousel-inner .next { left: 33%; } .carousel-inner .prev { left: -33%; }
另一个变化是仅显示下一张和上一张幻灯片的一部分。这可以通过在carousel-inner.. 的左侧和右侧上放置绝对位置叠加来完成。
carousel-inner
.carousel-inner:before { position:absolute; top:0; bottom: 0; right: 82%; left: 0; content:""; display:block; background-color: #fff; z-index: 2; } .carousel-inner:after { position:absolute; top:0; bottom:0; right: 0; left: 82%; content:""; display:block; background-color:#fff; z-index: 2; }