如何使我的图像轮播响应移动尺寸的显示1图像?

时间:2017-02-27 14:38:20

标签: javascript jquery html twitter-bootstrap carousel

目前Carousel显示了3张图片,这些图片在移动设备上非常棒,我想要显示可以浏览的单个图片,任何人都可以编辑我的代码或者按照正确的方向推动我如何实现它 这是html:

    <div class="container-fluid imageCarousel">
    <div class="row">
        <div class="col-md-12">
                <div id="myCarousel" class="container carousel fdi-Carousel slide">
                 <!-- Carousel items -->
                    <div class="carousel fdi-Carousel slide" id="eventCarousel" data-interval="0">
                        <div class="carousel-inner onebyone-carosel">
                            <div class="item active">
                                <div class="col-md-4">
                                    <a href="#"><img src="img/home-image1.png" class="img-responsive center-block"></a>
                                </div>
                            </div>
                            <div class="item">
                                <div class="col-md-4">
                                    <a href="#"><img src="img/home-image2.png" class="img-responsive center-block"></a>
                                </div>
                            </div>
                            <div class="item">
                                <div class="col-md-4">
                                    <a href="#"><img src="img/home-image3.png" class="img-responsive center-block"></a>
                                </div>
                            </div>
                            <div class="item">
                                <div class="col-md-4">
                                    <a href="#"><img src="img/home-image4.png" class="img-responsive center-block"></a>
                                </div>
                            </div>
                        </div>
                        <a class="left carousel-control" href="#eventCarousel" data-slide="prev">&lsaquo;</a>
                        <a class="right carousel-control" href="#eventCarousel" data-slide="next">&rsaquo;</a>
                    </div>
                    <!--/carousel-inner-->
                </div><!--/myCarousel-->
        </div>
    </div>
</div>

这是当前的JS:

$(document).ready(function () {
$('#myCarousel').carousel({
    interval: 10000
})
$('.fdi-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));
    }
});

});

1 个答案:

答案 0 :(得分:0)

尝试为所有窗口大小设置col值。对于小型窗口设备,示例为col-sm-12 col-xs-12,对于较大的窗口设备,示例为col-md-12 col-lg-12