Bootstrap carousel轮转图的使用实例详解

本文详细讲解了Bootstrap Carousel组件的使用方法,包括如何创建轮转图,设置控制按钮,添加滑动效果,以及自定义样式。通过实例演示,帮助开发者实现动态展示图片或内容的轮转效果。
摘要由CSDN通过智能技术生成
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html>
<head>
<meta charset= "utf-8" >
<link rel= "stylesheet" href= "css/bootstrap.min.css" />
<style>
body {
padding: 10px;
margin: 10px;
}
</style>
</head>
<body>
<div id= "myCarousel" class= "carousel" >
<!--第一步:设计轮播图片的容器。-->
<!-- #slidershow 层添加 slide 样式,使用图片与图片切换效果有平滑感-->
<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>
<div class= "carousel-inner" >
<!--第三步:设计轮播图片播放区,使用 carousel-inner 样式来控制-->
<div class= "item active" >
<div class= "carousel-caption" >
<h4>标题一</h4>
<p>图片一内容简介</p>
</div>
</div>
<div class= "item" >
<div class= "carousel-caption" >
<h4>标题二/h4>
<p>图片二内容简介</p>
</div>
</div>
<div class= "item" >
<div class= "carousel-caption" >
<h4>标题三</h4>
<p>图片三内容简介</p>
</div>
</div>
</div>
<!--第四步:设计轮播图片控制器。向前播放left carousel-control和向后播放的控制器-->
<a class= "left carousel-control" href= "#myCarousel" data-slide= "prev" >‹
<!--<a class= "left carousel-control" href= "#slidershow" role= "button" data-slide= "prev" >-->
<span class= "qlyphicon glyphicon-chevron-left" ></span></a>
<a class= "right carousel-control" href= "#myCarousel" data-slide= "next" >›
<span class= "qlyphicon glyphicon-chevron-right" ></span></a>
<!--<a class= "left carousel-control" href= "#carousel-example-generic" data-slide= "prev" >
<span class= "qlyphicon glyphicon-chevron-left" ></span>
</a>
<a class= "left carousel-control" href= "#carousel-example-generic" data-slide= "next" >
<span class= "qlyphicon glyphicon-chevron-right" ></span>
</a>-->
</div>
<script>
$( '.carousel' ).carousel()
</script>
<script type= "text/javascript" src= "js/jquery.min.js" ></script>
<script type= "text/javascript" src= "js/bootstrap.min.js" ></script>
<!--<script src= "http://libs.baidu.com/jquery/1.9.0/jquery.js" ></script>-->
</body>
</html> 
/*bootstrap.css文件第5835行~第5863行*/
.carousel-indicators {
position: absolute; /*整个计数区域绝对定位*/
bottom: 10px; /*距容器carousel底部10px*/
z-index: 15; /*设置其在Z轴的层级*/
/*让整个计数区水平居中*/
left: 50%;
width: 60%;
padding-left: 0;
margin-left: -30%;
text-align: center;
list-style: none;
}
.carousel-indicators li {
display: inline-block;
width: 10px;
height: 10px;
margin: 1px;
text-indent: -999px;
cursor: pointer;
background-color: #000 \9;
background-color: rgba(0, 0, 0, 0);
border: 1px solid #fff;
border-radius: 10px;
}
/*设置当前状态样式*/
.carousel-indicators .active {
width: 12px;
height: 12px;
margin: 0;
background-color: #fff;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值