如何使用Bootstrap轮播显示下一张图像?

时间:2016-03-21 11:02:10

标签: jquery css twitter-bootstrap

我正在制作自举旋转木马我必须制作一个旋转木马,其中第一张图像100%可见,第二张图像部分可见。

This is the type of slider I am looking for



<!DOCTYPE html>
<html>
    <head>
        <title>something</title>
        
        <script src="https://code.jquery.com/jquery.min.js"></script>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" />
        <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/js/bootstrap.min.js"></script>
    </head>
    <body>
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-12 center-block">
                    <div class="carousel slide" id="myCarousel">
                        <div class="carousel-inner">
                            <div class="item active">
                                <div class="col-xs-4"><a href="#"><img src="http://aszx.altervista.org/aatest/img/carousel/carousel-001.jpg" class="img-responsive"></a></div>
                            </div>
                            <div class="item">
                                <div class="col-xs-4"><a href="#"><img src="http://aszx.altervista.org/aatest/img/carousel/carousel-002.jpg" class="img-responsive"></a></div>
                            </div>
                            <div class="item">
                                <div class="col-xs-4"><a href="#"><img src="http://aszx.altervista.org/aatest/img/carousel/carousel-003.jpg" 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>
            </div>
        </div>
        <script>
            $(document).ready(function () {
                $('#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));
                    }
                });
            });
        </script>
        <style>
            .carousel {
                overflow: hidden;
            }
            .carousel-inner {
                width: 150%;
                left: -25%;
            }
            .carousel-inner > .item.next,
            .carousel-inner > .item.active.right {
                left: 0;
                -webkit-transform: translate3d(33%, 0, 0);
                transform: translate3d(33%, 0, 0);
            }
            .carousel-inner > .item.prev,
            .carousel-inner > .item.active.left {
                left: 0;
                -webkit-transform: translate3d(-33%, 0, 0);
                transform: translate3d(-33%, 0, 0);
            }
            .carousel-control.left, .carousel-control.right {
                background: rgba(255, 255, 255, 0.3);
                width: 25%;
            }
        </style>
    </body>
</html>
&#13;
&#13;
&#13;

我也考虑过这个作为参考,但它不适用于Firefox,我也不知道如何根据我的滑块解决这个问题。

感谢。

0 个答案:

没有答案