Twitter Bootstrap Carousel autoplay on load

前端 未结 10 1139
天命终不由人
天命终不由人 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:01

    As per the docs, you need to initialize the Carousel plugin via JavaScript. The carousel example on the official Bootstrap documentation page is initialized in the application.js file on lines 67-68:

    // carousel demo
    $('#myCarousel').carousel()
    

    which gives it the default settings.

    If you want to specify the cycle interval, you can set the interval property in milliseconds:

    $('.carousel').carousel({
      interval: 2000
    })
    

提交回复
热议问题