Bootstrap carousel multiple frames at once

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

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

\"enter

In

14条回答
  •  迷失自我
    2020-11-22 07:57

    This is a working twitter bootstrap 3.

    Here is the 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));
        }
    });
    

    And the css:

    .carousel-inner .active.left  { left: -33%;             }
    .carousel-inner .active.right { left: 33%;              }
    .carousel-inner .next         { left: 33%               }
    .carousel-inner .prev         { left: -33%              }
    .carousel-control.left        { background-image: none; }
    .carousel-control.right       { background-image: none; }
    .carousel-inner .item         { background: white;      }
    

    You can see it in action at this Jsfiddle

    The reason i added this answer because the other ones don't work entirely. I found 2 bugs inside them, one of them was that the left arrow generated a strange effect and the other was about the text getting bold in some situations witch can be resolved by setting the background color so the bottom item wont be visible while the transition effect.

提交回复
热议问题