Bootstrap 輪播(Carousel)自動播放例項
阿新 • • 發佈:2018-11-29
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="3000">
<!-- 輪播(Carousel)指標 -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<!-- 輪播(Carousel)專案 -->
<div class="carousel-inner">
<div class="item active">
<img src="/access/imgs/head1.jpg" style="width: 100%;height: 200px" alt="First slide">
</div>
<div class="item">
<img src="/access/imgs/head2.jpg" style="width: 100%;height: 200px" alt="Second slide">
</div>
<div class="item">
<img src="/access/imgs/head3.jpg" style="width: 100%;height: 200px" alt="Third slide">
</div>
</div>
<!-- 輪播(Carousel)導航 -->
<a class="left carousel-control" href="#myCarousel" 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="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
data 屬性 | 屬性值 | 描述 |
---|---|---|
data-interval | 3000 | 自動迴圈每個專案之間延遲的時間量 |
data-ride | carousel | 用於標記輪播在頁面載入時就開始動畫播放 |
data-slide-to | 索引值 | 將把滑塊移動到一個特定的索引,索引從 0 開始計數 |
data-target | 目標ID | 設定目標,指定要操作的元素 |
data-slide | prev 或 next | 用來改變幻燈片相對於當前位置的位置 |
摘自:http://www.runoob.com/bootstrap/bootstrap-carousel-plugin.html