bootstrap怎么修改轮播速度

2025-11-07 11:48:03

1、打开vs2017

bootstrap怎么修改轮播速度

2、为了快速的搭建一个bootstrap环境

我们新建一个MVC的工程

bootstrap怎么修改轮播速度

3、选择MVC

生成的项目中,已经包含bootstrap了

bootstrap怎么修改轮播速度

bootstrap怎么修改轮播速度

4、轮播时bootstrap的carousel 插件

我们将home index改造一下,先添加一个轮播

<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">

        <!-- Indicators -->

        <ol class="carousel-indicators">

            <li data-target="#carousel-example-generic" data-slide-to="0" class="active"> </li>

            <li data-target="#carousel-example-generic" data-slide-to="1"></li>

            <li data-target="#carousel-example-generic" data-slide-to="2"></li>

        </ol>

        <!-- Wrapper for slides -->

        <div class="carousel-inner" role="listbox">

            <div class="item active"  style="height:150px;background-color:black">

            

                <div class="carousel-caption" >

                   轮播1

                </div>

            </div>

            <div class="item" style="height:150px; background-color:black">

               

                <div class="carousel-caption">

                    轮播2

                </div>

            </div>

            ...

        </div>

        <!-- Controls -->

        <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">

            <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>

            <span class="sr-only">Previous</span>

        </a>

        <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">

            <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>

            <span class="sr-only">Next</span>

        </a>

    </div>

bootstrap怎么修改轮播速度

5、运行起来就能看到轮播的效果

bootstrap怎么修改轮播速度

6、这是一个最基本的轮播

要想控制轮播的速度需要写js来进行控制

bootstrap怎么修改轮播速度

7、控制轮播的速度是一个可设定的属性

interval 单位是毫秒

填入控制代码

       $('.carousel').carousel({

                interval: 2000

            })

bootstrap怎么修改轮播速度

8、修改完成后,在运行画面

就可以看到轮播的间隔已经变了

bootstrap怎么修改轮播速度

bootstrap怎么修改轮播速度

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢