Twitter Bootstrap Carousel autoplay on load

前端 未结 10 997
天命终不由人
天命终不由人 2021-02-07 03:15

Using the twitter bootstrap framework, how is it possible to invoke the carousel to \'auto slide.\' Meaning when the page loads, the carousel automatically scrolls.

I ha

相关标签:
10条回答
  • 2021-02-07 04:13

    Simply add the class "slide" to the carousel div tag, like this:

    <div class="carousel slide" id="this-carousel-id">
    
    0 讨论(0)
  • 2021-02-07 04:18

    For Bootstrap 4 and onwards:

    $(function(){
        $('.carousel').carousel({
          interval: 2000,
          ride: 'carousel' // this is the important part
        });
    });
    
    0 讨论(0)
  • 2021-02-07 04:20

    <div id="myCarousel" class="carousel slide" data-ride="carousel"> works for me, what I have been missing was the data-ride attribute.

    I hope this will help a lot of people. Thank you stackoverflow, you have been very useful to me on most grounds. Am glad this community exists.

    0 讨论(0)
  • 2021-02-07 04:21

    Just add data-interval="5000" to the div with the IP carouselExampleIndicators.

    Like this:

    <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel" data-interval="5000">
    
    0 讨论(0)
提交回复
热议问题