Bootstrap輪播圖的使用和理解4
本文實(shí)例為大家分享了Bootstrap輪播圖的實(shí)現(xiàn)代碼,供大家參考,具體內(nèi)容如下
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 模板</title>
<link href="lib/bootstrap/css/bootstrap.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
img {
width: 100%;
height: 100%;
}
p {
text-align: center;
}
</style>
</head>
<body>
<!-- 輪播圖部分 -->
<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">
<img src="images/輪播1.png" alt="輪播圖1">
<div class="carousel-caption">
輪播圖1
</div>
</div>
<div class="item">
<img src="images/輪播2.png" alt="輪播圖2">
<div class="carousel-caption">
輪播圖2
</div>
</div>
<div class="item">
<img src="images/輪播3.png" alt="輪播圖3">
<div class="carousel-caption">
輪播圖3
</div>
</div>
<p>輪播圖嘗試</p>
</div>
<!-- Controls -->
<!-- 控制 -->
<!-- 向左滑動(dòng) -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="false"></span>
<span class="sr-only">Previous</span>
</a>
<!-- 向右滑動(dòng) -->
<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>
<!-- js控制輪播圖 -->
<button id="prev">向前</button>
<button id="next">向后</button>
<button id="pause">停止</button>
<button id="start">開始</button>
<button id="jump">到第二張</button>
<script src="lib/jquery/jquery.js"></script>
<script src="lib/bootstrap/js/bootstrap.js"></script>
<!-- 輪播圖還支持js控制 -->
<script>
$(function(){
$('.carousel').carousel({
interval: 2000,//輪播間隔
pause:"hover", //鼠標(biāo)懸停在輪播圖上,是否停止?jié)L動(dòng)
wrap:true, //
keyboard:true //響應(yīng)鍵盤事件
});
$("#prev").click(function(event) {
$('.carousel').carousel('prev')// 周期上一個(gè)項(xiàng)目。
});
$("#next").click(function(event) {
$('.carousel').carousel('next')// 周期到下一個(gè)項(xiàng)目。
});;
$("#pause").click(function(event) {
$('.carousel').carousel('pause')// 從通過項(xiàng)目循環(huán)停止傳送帶。
});;
$("#start").click(function(event) {
$('.carousel').carousel('cycle')// 通過傳送帶項(xiàng)目周期從左到右。
});;
$("#jump").click(function(event) {
$('.carousel').carousel(1)// 循環(huán)傳送帶到一個(gè)特定的幀(0為主,類似于數(shù)組)。
});;
});
</script>
</body>
</html>
如果大家還想深入學(xué)習(xí),可以點(diǎn)擊這里進(jìn)行學(xué)習(xí),再為大家附3個(gè)精彩的專題:
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 利用BootStrap的Carousel.js實(shí)現(xiàn)輪播圖動(dòng)畫效果
- 使用BootStrap進(jìn)行輪播圖的制作
- BootStrap實(shí)現(xiàn)輪播圖效果(收藏)
- 使用BootStrap建立響應(yīng)式網(wǎng)頁(yè)——通欄輪播圖(carousel)
- Bootstrap幻燈片輪播圖支持觸屏左右手勢(shì)滑動(dòng)的實(shí)現(xiàn)方法
- BootStrap實(shí)現(xiàn)手機(jī)端輪播圖左右滑動(dòng)事件
- 通過BootStrap實(shí)現(xiàn)輪播圖的實(shí)際應(yīng)用
- Bootstrap開發(fā)實(shí)戰(zhàn)之響應(yīng)式輪播圖
- Bootstrap每天必學(xué)之響應(yīng)式導(dǎo)航、輪播圖
- Bootstrap實(shí)現(xiàn)基于carousel.js框架的輪播圖效果
相關(guān)文章
JavaScript中cookie工具函數(shù)封裝的示例代碼
這篇文章給大家主要介紹了JavaScript中cookie工具函數(shù)的封裝,文中給出了詳細(xì)的實(shí)現(xiàn)步驟和示例代碼,相信會(huì)對(duì)大家的理解很有幫助,有需要的朋友們下面來一起看看吧。2016-10-10
使用JavaScript實(shí)現(xiàn)Java的List功能(實(shí)例講解)
使用JavaScript實(shí)現(xiàn)Java的List功能(實(shí)例講解)。需要的朋友可以過來參考下,希望對(duì)大家有所幫助2013-11-11
整理Javascript數(shù)組學(xué)習(xí)筆記
整理Javascript數(shù)組學(xué)習(xí)筆記,之前一系列的文章是跟我學(xué)習(xí)Javascript,本文就是進(jìn)一步學(xué)習(xí)javascript數(shù)組,希望大家繼續(xù)關(guān)注2015-11-11
JS與HTML結(jié)合實(shí)現(xiàn)流程進(jìn)度展示條思路詳解
基于js與html相結(jié)合實(shí)現(xiàn)的流程進(jìn)度展示條,非常實(shí)用,在各大網(wǎng)站都可以用到,下面小編給大家?guī)砹薐S與HTML結(jié)合實(shí)現(xiàn)流程進(jìn)度展示條思路詳解,需要的朋友參考下吧2017-09-09
js實(shí)現(xiàn)當(dāng)鼠標(biāo)移到表格上時(shí)顯示這一格全部?jī)?nèi)容的代碼
下面小編就為大家?guī)硪黄猨s實(shí)現(xiàn)當(dāng)鼠標(biāo)移到表格上時(shí)顯示這一格全部?jī)?nèi)容的代碼。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-06-06
iframe的onload在Chrome/Opera中執(zhí)行兩次Bug的解決方法
創(chuàng)建iframe對(duì)象,添加load事件, 再將iframe添加到body中。Chrome/Opera中會(huì)造成load事件的handler執(zhí)行兩次。2011-03-03
微信小程序?qū)崿F(xiàn)點(diǎn)擊圖片放大預(yù)覽
這篇文章主要為大家詳細(xì)介紹了小程序?qū)崿F(xiàn)點(diǎn)擊圖片放大預(yù)覽功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-10-10
js實(shí)現(xiàn)網(wǎng)站首頁(yè)圖片滾動(dòng)顯示
網(wǎng)站首頁(yè)圖片滾動(dòng)顯示對(duì)于很多朋友都有很大的吸引,因?yàn)樗梢詭硪庀氩坏揭曈X沖擊效果,接下來本文也實(shí)現(xiàn)一下,感興趣的朋友可以參考下,或許對(duì)你學(xué)習(xí)js知識(shí)有所幫助2013-02-02

