简体   繁体   English

在bootstrap Carousel中显示下一个图像

[英]Show the next image in bootstrap Carousel

I want to show ONLY the next image and hide the previous image. 我想只显示下一张图像并隐藏上一张图像。 Basically, I want the main image to cover 80% of the screen and the next image to cover 20% of the screen. 基本上,我希望主图像覆盖80%的屏幕,下一个图像覆盖20%的屏幕。

This code I have currently covers roughly 25% for the previous image, 50% for the current image, 25% for the next image. 我目前的代码覆盖了前一个图像的大约25%,当前图像的50%,下一个图像的25%。 How do I go about this? 我该怎么做?

HTML: HTML:

        <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>

JS: JS:

<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>

CSS: CSS:

<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>

DEMO DEMO

Try this 尝试这个

.carousel-inner{width:200%;left:5%;}

DEMO DEMO

.carousel-inner {
                width: 300%;
                left: -25%;
            }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Twitter Bootstrap Carousel中显示下一张和上一张图片 - Show next and previous image in Twitter Bootstrap Carousel 具有上一个和下一个箭头的Bootstrap轮播图像指示器 - Bootstrap carousel image indicator with prev and next arrow 显示带有引导轮播的预览(上一张和下一张图片) - Showing previews (previous and next image) with bootstrap carousel 如何使twitter bootstrap 3轮播中心处于活动图像的中心,并显示下一张和上一张图像的一部分? - How can I make twitter bootstrap 3 carousel centre the active image and show part of the next and previous images? 单击引导轮播中的下一个或上一个时,图像会跳转 - Image jumps when click on next or previous on bootstrap carousel 如何将所选图像设置为在 Angular 的引导轮播中显示的第一张图像? - How to set the selected image as the first image to show in a bootstrap carousel in Angular? Bootstrap 5 - 轮播不会滑动到下一个图像 - 从 bootstrap 4 升级到 bootstrap 5 - Bootstrap 5 - Carousel won't slide to next image - upgrade from bootstrap 4 to bootstrap 5 引导轮播TypeError:$ next [0]未定义 - Bootstrap carousel TypeError: $next[0] is undefined 对齐Bootstrap轮播图片 - Align Bootstrap Carousel Image bootstrap carousel图像高度 - bootstrap carousel image height
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM