bootstrap 轮播图代码
时间: 2023-12-20 19:29:13 浏览: 85
Bootstrap carousel轮转图的使用实例详解
Bootstrap是一个流行的前端框架,它提供了许多易于使用的组件和工具,其中包括轮播图组件。下面是Bootstrap轮播图的代码:
```
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="..." alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="..." alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="..." alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
```
其中,`carouselExampleIndicators`是轮播图的ID,`carousel-indicators`是轮播图的指示器,`carousel-inner`是轮播图的内容,`carousel-control-prev`和`carousel-control-next`是轮播图的控制按钮。
如果你想改变过渡的时间,可以使用以下代码:
```
.carousel-inner .carousel-item {
transition-duration: 2s; /* 修改过渡时间为2秒 */
}
```
阅读全文