Bootstrap carousel multiple frames at once

前端 未结 14 1060
清酒与你
清酒与你 2020-11-22 07:51

This is the effect I\'m trying to achieve with Bootstrap 3 carousel

\"enter

In

相关标签:
14条回答
  • 2020-11-22 08:18

        $('#carousel-example-generic').on('slid.bs.carousel', function () {
            $(".item.active:nth-child(" + ($(".carousel-inner .item").length -1) + ") + .item").insertBefore($(".item:first-child"));
            $(".item.active:last-child").insertBefore($(".item:first-child"));
        });    
            .item.active,
            .item.active + .item,
            .item.active + .item  + .item {
               width: 33.3%;
               display: block;
               float:left;
            }          
       <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
    
    <div id="carousel-example-generic" class="carousel slide" data-ride="carousel" style="max-width:800px;">
      <!-- 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>
        <li data-target="#carousel-example-generic" data-slide-to="2"></li>
      </ol>
    
      <!-- Wrapper for slides -->
      <div class="carousel-inner" role="listbox">
        <div class="item active">
            <img data-src="holder.js/300x200?text=1">
        </div>
        <div class="item">
            <img data-src="holder.js/300x200?text=2">
        </div>
        <div class="item">
            <img data-src="holder.js/300x200?text=3">
        </div>
        <div class="item">
            <img data-src="holder.js/300x200?text=4">
        </div>
        <div class="item">
            <img data-src="holder.js/300x200?text=5">
        </div>
        <div class="item">
            <img data-src="holder.js/300x200?text=6">
        </div>
        <div class="item">
            <img data-src="holder.js/300x200?text=7">
        </div>    
      </div>
    
      <!-- Controls -->
      <a class="left carousel-control" href="#carousel-example-generic" 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="#carousel-example-generic" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
      </a>
    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/holder/2.9.1/holder.min.js"></script>
        

    0 讨论(0)
  • 2020-11-22 08:19

    All the above solutions are hacky and buggy. Don't even try. Use other libs. The best I have found - http://sachinchoolur.github.io/lightslider Works great with bootstrap, does not add junk html, highly-configurable, responsive, mobile-friendly etc...

    $('.multi-item-carousel').lightSlider({
        item: 4,
        pager: false,
        autoWidth: false,
        slideMargin: 0
    });
    
    0 讨论(0)
提交回复
热议问题