示例 2 : 带标题的轮播 示例 3 : 设置轮播速度 示例 4 : 控制前后的轮播
基本轮播
<!DOCTYPE html>
<script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
<link href="https://how2j.cn/study/css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script>
<style>
div.item img{
width:100%;
}
div#carousel-example-generic{
width:80%;
margin:0 auto;
}
</style>
<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>
<li data-target="#carousel-example-generic" data-slide-to="3"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="https://how2j.cn/img/site/step/3491.png" >
</div>
<div class="item">
<img src="https://how2j.cn/img/site/step/3492.png" >
</div>
<div class="item">
<img src="https://how2j.cn/img/site/step/3493.png" >
</div>
<div class="item">
<img src="https://how2j.cn/img/site/step/3494.png" >
</div>
</div>
</div>
带标题的轮播
<!DOCTYPE html>
<script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
<link href="https://how2j.cn/study/css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script>
<style>
div.item img{
width:100%;
}
div#carousel-example-generic{
width:80%;
margin:0 auto;
}
</style>
<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>
<li data-target="#carousel-example-generic" data-slide-to="3"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="https://how2j.cn/img/site/step/3491.png" >
<div class="carousel-caption">
LOL1
</div>
</div>
<div class="item">
<img src="https://how2j.cn/img/site/step/3492.png" >
<div class="carousel-caption">
LOL2
</div>
</div>
<div class="item">
<img src="https://how2j.cn/img/site/step/3493.png" >
<div class="carousel-caption">
LOL3
</div>
</div>
<div class="item">
<img src="https://how2j.cn/img/site/step/3494.png" >
<div class="carousel-caption">
LOL4
</div>
</div>
</div>
</div>
设置轮播速度
<!DOCTYPE html>
<script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
<link href="https://how2j.cn/study/css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script>
<style>
div.item img{
width:100%;
}
div#carousel-example-generic{
width:80%;
margin:0 auto;
}
</style>
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel" data-interval="1000">
<!-- 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>
<li data-target="#carousel-example-generic" data-slide-to="3"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="https://how2j.cn/img/site/step/3491.png" >
</div>
<div class="item">
<img src="https://how2j.cn/img/site/step/3492.png" >
</div>
<div class="item">
<img src="https://how2j.cn/img/site/step/3493.png" >
</div>
<div class="item">
<img src="https://how2j.cn/img/site/step/3494.png" >
</div>
</div>
</div>
控制前后的轮播
<!DOCTYPE html>
<script src="https://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
<link href="https://how2j.cn/study/css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="https://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script>
<style>
div.item img{
width:100%;
}
div#carousel-example-generic{
width:80%;
margin:0 auto;
}
</style>
<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>
<li data-target="#carousel-example-generic" data-slide-to="3"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="https://how2j.cn/img/site/step/3491.png" >
</div>
<div class="item">
<img src="https://how2j.cn/img/site/step/3492.png" >
</div>
<div class="item">
<img src="https://how2j.cn/img/site/step/3493.png" >
</div>
<div class="item">
<img src="https://how2j.cn/img/site/step/3494.png" >
</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>
</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>
</a>
</div>
HOW2J公众号,关注后实时获知最新的教程和优惠活动,谢谢。
问答区域
2019-09-27
为什么我轮播的时候的图片会一点一点增大
回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
2019-02-28
请问怎样才能让图片自适应大小
2018-11-10
data-target 属性值
2017-08-03
data-ride="carousel
2017-03-07
就是引用了自己下载的bootsrap.js bootsrap.css jq 就没有出现箭头了不知道什么原因,用楼主的就可以
提问太多,页面渲染太慢,为了加快渲染速度,本页最多只显示几条提问。还有 1 条以前的提问,请 点击查看
提问之前请登陆
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
|