Bootstrap carousel multiple frames at once

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

    Can this be done with bootstrap 3's carousel? I'm hoping I won't have to go hunting for yet another jQuery plugin

    As of 2013-12-08 the answer is no. The effect you are looking for is not possible using Bootstrap 3's generic carousel plugin. However, here's a simple jQuery plugin that seems to do exactly what you want http://sorgalla.com/jcarousel/

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-11-22 07:57

    try this.....it work in mine.... code:

    <div class="container">
        <br>
        <div id="myCarousel" class="carousel slide" data-ride="carousel">
            <!-- Indicators -->
            <ol class="carousel-indicators">
                <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
                <li data-target="#myCarousel" data-slide-to="1"></li>
                <li data-target="#myCarousel" data-slide-to="2"></li>
                <li data-target="#myCarousel" data-slide-to="3"></li>
            </ol>
    
            <!-- Wrapper for slides -->
            <div class="carousel-inner" role="listbox">
                <div class="item active">
                    <div class="span4" style="padding-left: 18px;">
                        <img src="http://placehold.it/290x180" class="img-thumbnail">
                        <img src="http://placehold.it/290x180" class="img-thumbnail">
                        <img src="http://placehold.it/290x180" class="img-thumbnail">
                    </div>
                </div>
                <div class="item">
                     <div class="span4" style="padding-left: 18px;">
                        <img src="http://placehold.it/290x180" class="img-thumbnail">
                        <img src="http://placehold.it/290x180" class="img-thumbnail">
                        <img src="http://placehold.it/290x180" class="img-thumbnail">
                    </div>
                </div>
            </div>
            <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
                <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                <span class="sr-only">Next</span>
            </a>
        </div>
    </div>
    
    0 讨论(0)
  • 2020-11-22 07:58

    I've seen your question and answers, and made a new responsive and flexible multi items carousel Gist. you can see it here:

    https://gist.github.com/IVIR3zaM/d143a361e61459146ae7c68ce86b066e

    0 讨论(0)
  • 2020-11-22 07:59
    Try this code
    
    
     <div id="recommended-item-carousel" class="carousel slide" data-ride="carousel">
        <div class="carousel-inner">
            <div class="item active">
    
                <div class="col-sm-3">
                    <div class="product-image-wrapper">
                        <div class="single-products">
                            <div class="productinfo text-center">
                                <img src="img/home/recommend1.jpg" alt="" />
                                <h2>$56</h2>
                                <p>
                                    Easy Polo Black Edition
                                </p>
                                <a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
                            </div>
    
                        </div>
                    </div>
                </div>
                <div class="col-sm-3">
                    <div class="product-image-wrapper">
                        <div class="single-products">
                            <div class="productinfo text-center">
                                <img src="img/home/recommend2.jpg" alt="" />
                                <h2>$56</h2>
                                <p>
                                    Easy Polo Black Edition
                                </p>
                                <a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
                            </div>
    
                        </div>
                    </div>
                </div>
                <div class="col-sm-3">
                    <div class="product-image-wrapper">
                        <div class="single-products">
                            <div class="productinfo text-center">
                                <img src="img/home/recommend3.jpg" alt="" />
                                <h2>$56</h2>
                                <p>
                                    Easy Polo Black Edition
                                </p>
                                <a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
                            </div>
    
                        </div>
                    </div>
                </div>
            </div>
            <div class="item">
                <div class="col-sm-3">
                    <div class="product-image-wrapper">
                        <div class="single-products">
                            <div class="productinfo text-center">
                                <img src="img/home/recommend1.jpg" alt="" />
                                <h2>$56</h2>
                                <p>
                                    Easy Polo Black Edition
                                </p>
                                <a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
                            </div>
    
                        </div>
                    </div>
                </div>
                <div class="col-sm-3">
                    <div class="product-image-wrapper">
                        <div class="single-products">
                            <div class="productinfo text-center">
                                <img src="img/home/recommend2.jpg" alt="" />
                                <h2>$56</h2>
                                <p>
                                    Easy Polo Black Edition
                                </p>
                                <a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
                            </div>
    
                        </div>
                    </div>
                </div>
                <div class="col-sm-3">
                    <div class="product-image-wrapper">
                        <div class="single-products">
                            <div class="productinfo text-center">
                                <img src="img/home/recommend3.jpg" alt="" />
                                <h2>$56</h2>
                                <p>
                                    Easy Polo Black Edition
                                </p>
                                <a href="#" class="btn btn-default add-to-cart"><i class="fa fa-shopping-cart"></i>Add to cart</a>
                            </div>
    
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <a class="left recommended-item-control" href="#recommended-item-carousel" data-slide="prev"> <i class="fa fa-angle-left"></i> </a>
        <a class="right recommended-item-control" href="#recommended-item-carousel" data-slide="next"> <i class="fa fa-angle-right"></i> </a>
    </div>
    
    0 讨论(0)
  • 2020-11-22 08:00

    I had the same problem and the solutions described here worked well. But I wanted to support window size (and layout) changes. The result is a small library that solves all the calculation. Check it out here: https://github.com/SocialbitGmbH/BootstrapCarouselPageMerger

    To make the script work, you have to add a new <div> wrapper with the class .item-content directly into your .item <div>. Example:

    <div class="carousel slide multiple" id="very-cool-carousel" data-ride="carousel">
        <div class="carousel-inner" role="listbox">
            <div class="item active">
                <div class="item-content">
                    First page
                </div>
            </div>
            <div class="item active">
                <div class="item-content">
                    Second page
                </div>
            </div>
        </div>
    </div>
    

    Usage of this library:

    socialbitBootstrapCarouselPageMerger.run('div.carousel');
    

    To change the settings:

    socialbitBootstrapCarouselPageMerger.settings.spaceCalculationFactor = 0.82;
    

    Example:

    As you can see, the carousel gets updated to show more controls when you resize the window. Check out the watchWindowSizeTimeout setting to control the timeout for reacting to window size changes.

    0 讨论(0)
提交回复
热议问题