繁体   English   中英

Bootstrap v4传送带未初始化

[英]Bootstrap v4 Carousel Not Initializing

我正在尝试让Bootstrap v4滑块正常工作。

它应该在滑块的右边有文本,并且该文本随每张幻灯片而变化。

我已经添加了所需的CSS / JS,但滑块不会初始化。

链接到JS FIDDLE

我的JS:

<script>
        $( document ).ready(function() {
        //set here the speed to change the slides in the carousel
        $('#features').carousel({});

//Loads the html to each slider. Write in the "div id="slide-content-x" what you want to show in each slide
        $('#carousel-text').html($('#slide-content-0').html());


        // When the carousel slides, auto update the text
        $('#features').on('slid.bs.carousel', function (e) {
                 var id = $('.item.active').data('slide-number');
                $('#carousel-text').html($('#slide-content-'+id).html());
        });
});

    </script>

看起来您在示例中的标记是不够的。

您有一个.carousel-inner div容器, .carousel-inner没有.carousel-item 当然,那只是一张幻灯片。

尝试遵循引导文档提供的示例

将您的#slide-content-x容器放入多个.carousel-inner div .carousel-inner并删除您的JS解决方法。

您不需要任何JS。 它是自我初始化的。

在这里查看我的工作示例: https : //jsfiddle.net/y8h5oqfw/2/

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM