bootstrap专栏 06.组件 07.轮播图

本文详细介绍了如何使用HTML5和JavaScript创建一个轮播图,包括HTML结构、CSS样式和JavaScript交互。示例代码展示了轮播图的图文内容、切换效果以及控制按钮的实现,同时提供了设置轮播时间的JS代码。通过此教程,读者可以了解到轮播图的基本构建和动态展示方法。
摘要由CSDN通过智能技术生成

# 07.轮播图

[toc]{type: "ol", level: [3]}

### 轮播图
```html
<div id="carouselExampleCaptions" class="carousel slide w-100" data-ride="carousel">
    <ol class="carousel-indicators">
        <li data-target="#carouselExampleCaptions" data-slide-to="0" class="active"></li>
        <li data-target="#carouselExampleCaptions" data-slide-to="1"></li>
        <li data-target="#carouselExampleCaptions" data-slide-to="2"></li>
    </ol>

    <div class="carousel-inner h-100 w-100">
        <!--图文1-->
        <div class="carousel-item active">
            <img src="../img/carousel-1.jpg" class="d-block w-100" alt="...">
            <div class="carousel-caption d-none d-md-block">
                <h5>First slide label</h5>
                <p>Some representative placeholder content for the first slide.</p>
            </div>
        </div>
        <!--图文2-->
        <div class="carousel-item">
            <img src="../img/carousel-2.jpg" class="d-block w-100" alt="...">
            <div class="carousel-caption d-none d-md-block">
                <h5>Second slide label</h5>
                <p>Some representative placeholder content for the second slide.</p>
            </div>
        </div>
        <!--图文3-->
        <div class="carousel-item">
            <img src="../img/carousel-3.jpg" class="d-block w-100" alt="...">
            <div class="carousel-caption d-none d-md-block">
                <h5>Third slide label</h5>
                <p>Some representative placeholder content for the third slide.</p>
            </div>
        </div>
    </div>

    <!--上一个按钮-->
    <button class="carousel-control-prev" type="button" data-target="#carouselExampleCaptions" data-slide="prev">
        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
    </button>
    <!--下一个按钮-->
    <button class="carousel-control-next" type="button" data-target="#carouselExampleCaptions" data-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
    </button>
</div>
```
```js
    // 设置轮播时间
    $('.carousel').carousel( {interval:6000})
```
![轮播图-轮播图-1](07.轮播图-轮播图-1.png)
![轮播图-轮播图-2](07.轮播图-轮播图-2.png)
![轮播图-轮播图-3](07.轮播图-轮播图-3.png)

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值