Preventing twitter bootstrap carousel from auto sliding on page load

后端 未结 10 1703
萌比男神i
萌比男神i 2020-12-07 17:13

So is there anyway to prevent twitter bootstrap carousel from auto sliding on the page load unless the next or previous button is clicked?

Thanks

相关标签:
10条回答
  • 2020-12-07 17:50

    if you're using bootstrap 3 set data-interval="false" on the HTML structure of carousel

    example:

    <div id="carousel-example-generic" class="carousel slide" data-ride="carousel" data-interval="false">
    
    0 讨论(0)
  • 2020-12-07 17:59

    For Bootstrap 4 simply remove the 'data-ride="carousel"' from the carousel div. This removes auto play at load time.

    To enable the auto play again you would still have to use the "play" call in javascript.

    0 讨论(0)
  • 2020-12-07 18:00

    I think maybe you should go to check the official instruction about carousel, for me, i have not found answer above, because of multiple versions of bootstrap, I'm using b4-alpha and i want the autoplay effect stop.

    $(document).ready({
        pause:true,
        interval:false
    });
    

    this script does not make any effect while mouse leave that page, exactly carousel area. go to official definition and find those :

    So you will find why.if carousel page onmouseover event triggered, page will pause, while mouse out of that page, it'll resume again.

    So, if you want a page stop forever and rotate manually, you can just set data-interval='false'.

    0 讨论(0)
  • 2020-12-07 18:01

    add this to your coursel div :

    data-interval="false"
    
    0 讨论(0)
提交回复
热议问题