【问题标题】:Lightbox+bootstrap gallery, thumbnails灯箱+引导库,缩略图
【发布时间】:2014-08-25 05:58:29
【问题描述】:
我需要一个解决方案。
现在我有带有主图像的产品和它下面的一些其他照片。
如果照片超过 3 张,我需要像轮播一样展示它们,而不是像 no 一样按 3 行显示。
附上img,解释一下。
*第 4、5 等照片应隐藏在轮播中。
*点击后所有图片都会弹出。
【问题讨论】:
标签:
javascript
jquery
twitter-bootstrap-3
【解决方案1】:
您可以使用 Bootstrap 来做到这一点,但您需要做一些解决方法,因为它不是开箱即用的。
假设这是你的 HTML:
<div class="col-md-7">
<div class="carousel slide" id="myCarousel">
<div class="carousel-inner">
<div class="item active">
<div class="col-md-4"><a href="#"><img src="http://placehold.it/500/bbbbbb/fff&text=1" class="img-responsive"></a></div>
</div>
<div class="item">
<div class="col-md-4"><a href="#"><img src="http://placehold.it/500/CCCCCC&text=2" class="img-responsive"></a></div>
</div>
<div class="item">
<div class="col-md-4"><a href="#"><img src="http://placehold.it/500/eeeeee&text=3" class="img-responsive"></a></div>
</div>
<div class="item">
<div class="col-md-4"><a href="#"><img src="http://placehold.it/500/f4f4f4&text=4" class="img-responsive"></a></div>
</div>
<div class="item">
<div class="col-md-4"><a href="#"><img src="http://placehold.it/500/fcfcfc/333&text=5" class="img-responsive"></a></div>
</div>
<div class="item">
<div class="col-md-4"><a href="#"><img src="http://placehold.it/500/f477f4/fff&text=6" class="img-responsive"></a></div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev"><i class="glyphicon glyphicon-chevron-left"></i></a>
<a class="right carousel-control" href="#myCarousel" data-slide="next"><i class="glyphicon glyphicon-chevron-right"></i></a>
</div>
</div>
解决方法 JavaScript:
$('#myCarousel').carousel({
interval: 10000
})
$('.carousel .item').each(function(){
var next = $(this).next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
if (next.next().length>0) {
next.next().children(':first-child').clone().appendTo($(this));
}
else {
$(this).siblings(':first').children(':first-child').clone().appendTo($(this));
}
});
在这里工作演示:http://jsfiddle.net/6ouybst4/
现在自助并在其中实现灯箱 :-)