简体   繁体   English

灯箱+引导程序库,缩略图

[英]Lightbox+bootstrap gallery, thumbnails

i need to a solution. 我需要一个解决方案。 Now i have product with main image and some other photos under it. 现在我有带有主图像和其他图片的产品。 If photos are more than 3, i need to show them like carousel, not like no in rows by 3. 如果照片多于3张,我需要像轮播一样显示它们,而不是像3行一样显示否。

Attaching img, to explain it more. 附加img,以进行更多说明。

在此处输入图片说明

*4th,5th etc photo should be hidden in carousel. *第4张,第5张等照片应隐藏在转盘中。
*All images should popup if they are clicked. *如果单击所有图像,则应弹出。

You can possibly do it with Bootstrap but you need to do a bit of workaround since it is not available out of the box. 您可以使用Bootstrap进行此操作,但由于开箱即用,因此您需要做一些变通方法。

Suppose this is your HTML : 假设这是您的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&amp;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&amp;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&amp;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&amp;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&amp;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&amp;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>

Workaround JavaScript : 解决方法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));
  }
});

Working demo here : http://jsfiddle.net/6ouybst4/ 在这里工作演示: http : //jsfiddle.net/6ouybst4/

Now help yourself and implement lightbox in it :-) 现在,帮助自己并在其中实现灯箱:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM