Bootstrap carousel multiple frames at once

前端 未结 14 1065
清酒与你
清酒与你 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:04

    Reference to above link i added 1 new thing called show 4 at time, slide one at a time for bootstrap 3 (v3.3.7)

    CODEPLY:- https://www.codeply.com/go/eWUbGlspqU

    LIVE SNIPPET

    (function(){
      $('#carousel123').carousel({ interval: 2000 });
    }());
    
    (function(){
      $('.carousel-showmanymoveone .item').each(function(){
        var itemToClone = $(this);
    
        for (var i=1;i<4;i++) {
          itemToClone = itemToClone.next();
    
          // wrap around if at end of item collection
          if (!itemToClone.length) {
            itemToClone = $(this).siblings(':first');
          }
    
          // grab item, clone, add marker class, add to collection
          itemToClone.children(':first-child').clone()
            .addClass("cloneditem-"+(i))
            .appendTo($(this));
        }
      });
    }());
    body {
        margin-top: 50px;
    }
    
    .carousel-showmanymoveone .carousel-control {
      width: 4%;
      background-image: none;
    }
    .carousel-showmanymoveone .carousel-control.left {
      margin-left: 15px;
    }
    .carousel-showmanymoveone .carousel-control.right {
      margin-right: 15px;
    }
    .carousel-showmanymoveone .cloneditem-1,
    .carousel-showmanymoveone .cloneditem-2,
    .carousel-showmanymoveone .cloneditem-3 {
      display: none;
    }
    @media all and (min-width: 768px) {
      .carousel-showmanymoveone .carousel-inner > .active.left,
      .carousel-showmanymoveone .carousel-inner > .prev {
        left: -50%;
      }
      .carousel-showmanymoveone .carousel-inner > .active.right,
      .carousel-showmanymoveone .carousel-inner > .next {
        left: 50%;
      }
      .carousel-showmanymoveone .carousel-inner > .left,
      .carousel-showmanymoveone .carousel-inner > .prev.right,
      .carousel-showmanymoveone .carousel-inner > .active {
        left: 0;
      }
      .carousel-showmanymoveone .carousel-inner .cloneditem-1 {
        display: block;
      }
    }
    @media all and (min-width: 768px) and (transform-3d), all and (min-width: 768px) and (-webkit-transform-3d) {
      .carousel-showmanymoveone .carousel-inner > .item.active.right,
      .carousel-showmanymoveone .carousel-inner > .item.next {
        -webkit-transform: translate3d(50%, 0, 0);
                transform: translate3d(50%, 0, 0);
        left: 0;
      }
      .carousel-showmanymoveone .carousel-inner > .item.active.left,
      .carousel-showmanymoveone .carousel-inner > .item.prev {
        -webkit-transform: translate3d(-50%, 0, 0);
                transform: translate3d(-50%, 0, 0);
        left: 0;
      }
      .carousel-showmanymoveone .carousel-inner > .item.left,
      .carousel-showmanymoveone .carousel-inner > .item.prev.right,
      .carousel-showmanymoveone .carousel-inner > .item.active {
        -webkit-transform: translate3d(0, 0, 0);
                transform: translate3d(0, 0, 0);
        left: 0;
      }
    }
    @media all and (min-width: 992px) {
      .carousel-showmanymoveone .carousel-inner > .active.left,
      .carousel-showmanymoveone .carousel-inner > .prev {
        left: -25%;
      }
      .carousel-showmanymoveone .carousel-inner > .active.right,
      .carousel-showmanymoveone .carousel-inner > .next {
        left: 25%;
      }
      .carousel-showmanymoveone .carousel-inner > .left,
      .carousel-showmanymoveone .carousel-inner > .prev.right,
      .carousel-showmanymoveone .carousel-inner > .active {
        left: 0;
      }
      .carousel-showmanymoveone .carousel-inner .cloneditem-2,
      .carousel-showmanymoveone .carousel-inner .cloneditem-3 {
        display: block;
      }
    }
    @media all and (min-width: 992px) and (transform-3d), all and (min-width: 992px) and (-webkit-transform-3d) {
      .carousel-showmanymoveone .carousel-inner > .item.active.right,
      .carousel-showmanymoveone .carousel-inner > .item.next {
        -webkit-transform: translate3d(25%, 0, 0);
                transform: translate3d(25%, 0, 0);
        left: 0;
      }
      .carousel-showmanymoveone .carousel-inner > .item.active.left,
      .carousel-showmanymoveone .carousel-inner > .item.prev {
        -webkit-transform: translate3d(-25%, 0, 0);
                transform: translate3d(-25%, 0, 0);
        left: 0;
      }
      .carousel-showmanymoveone .carousel-inner > .item.left,
      .carousel-showmanymoveone .carousel-inner > .item.prev.right,
      .carousel-showmanymoveone .carousel-inner > .item.active {
        -webkit-transform: translate3d(0, 0, 0);
                transform: translate3d(0, 0, 0);
        left: 0;
      }
    }
    
    
    
    
    
    

提交回复
热议问题