bootstrap中的焦点图实例
使用html属性标记,代码如下:
- <div id="myCarousel" class="carousel">
- <!-- 要切换的内容-->
- <div class="carousel-inner">
- <div class="active item">…</div>
- <div class="item">…</div>
- <div class="item">…</div>
- </div>
- <!-- 切换导航 -->
- <a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
- <a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
- </div>
也可以在使用了.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(options)
初始化轮播组件,接受一个对象做为可选参数并开始循环播放.
例如:
- $(".carousel").carousel({
- interval:2000
- })
.carousel('cycle') 从左向右循环播放
.carousel('pause')中止播放
.carousel(number)播放到某个特定的帧(与数组类似,从0开始计数).
.carousel('prev') 回到上一帧
.carousel('next') 回到下一帧
轮播类提供了两个事件
slide 该事件在调用slide实例方法时立刻触发
slid 该事件在轮播项切换效果完成之后触发
本实例代码如下:
- <style>/*metro风格样式*/
- div, input, select, textarea, span, img, table, td, th, p, a, button, ul, li
- {
- border–radius: 0 0 0 0 !important;
- }
-
- [class^="m-icon-"]
- {
- display: inline–block;
- width: 14px;
- height: 14px;
- margin–top: 4px;
- line–height: 14px;
- vertical–align: top;
- background–image: url(http://www.kuiyu.net/content/bootstrap/img/syncfusion-icons.png);
- background–position: 0 0;
- background–repeat: no–repeat;
- }
-
- [class^="m-icon-big-"]
- {
- display: inline–block;
- width: 30px;
- height: 30px;
- margin: 6px;
- vertical–align: top;
- background–image: url(http://www.kuiyu.net/content/bootstrap/img/syncfusion-icons.png);
- background–position: 0 0px;
- background–repeat: no–repeat;
- }
-
- .m–icon–white
- {
- background–image: url(http://www.kuiyu.net/content/bootstrap/img/syncfusion-icons-twhite.png);
- }
-
- /* Misc */
- .btn.icn–only
- {
- min–width: 14px;
- }
- .btn.bigicn–only
- {
- min–width: 34px;
- }
- .m–icon–swapright
- {
- background–position: –27px –10px;
- }
- .m–icon–swapdown
- {
- background–position: –68px –10px;
- }
- .m–icon–swapleft
- {
- background–position: –8px –10px;
- }
- .m–icon–swapup
- {
- background–position: –46px –10px;
- }
- .m–icon–big–swapright
- {
- background–position: –42px –28px;
- }
- .m–icon–big–swapdown
- {
- background–position: –115px –28px;
- }
- .m–icon–big–swapleft
- {
- background–position: –6px –28px;
- }
- .m–icon–big–swapup
- {
- background–position: –78px –28px;
- }
-
- /*******************焦点图样式********************************************************/
- .carousel
- {
- margin–bottom: 0;
- }
-
- .carousel .carousel–caption a
- {
- color: #fff;
- }
-
- .carousel .carousel–inner .item
- {
- margin–bottom: 10px;
- height:360px;
- }
-
- .carousel a.carousel–control
- {
- border: none;
- padding: 5px;
- display: none;
- }
-
- .carousel:hover a.carousel–control
- {
- display: block;
- width: 40px;
- height: 40px;
- }
- </style>
- <div class="container">
- <div class="row-fluid">
- <div class="span7">
- <div id="myCarousel" class="carousel 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">
- <div class="active item">
- <img src="http://www.kuiyu.net/images/image5.jpg" />
- <div class="carousel-caption">
- <h4>
- <a href="http://www.kuiyu.net">奎宇工作室</a>
- </h4>
- <p>
- 奎宇工作室创建于2009年,专注于中小企业或个人互联信息化领域技术支持.
- </p>
- </div>
- </div>
- <div class="item">
- <img src="http://www.kuiyu.net/images/image4.jpg" />
- <div class="carousel-caption">
- <h4>
- <a href="http://www.kuiyu.net/tg/sdp">全球3D拍</a>
- </h4>
- <p>
- 让你足不出户游遍世界美景.
- </p>
- </div>
- </div>
- <div class="item">
- <img src="http://www.kuiyu.net/images/image3.jpg" />
- <div class="carousel-caption">
- <h4>
- <a target="_blank" href="http://www.kuiyu.net/tg/sst/">白富美普洱茶油贴</a>
- </h4>
- <p>
- 早上贴,晚上瘦,轻松减肥分健康生活!
- </p>
- </div>
- </div>
- <div class="item">
- <img src="http://www.kuiyu.net/images/image2.jpg" />
- <div class="carousel-caption">
- <h4>
- <a target="_blank" href="http://www.kuiyu.net/tg/zxkf/">左旋360咖啡</a>
- </h4>
- <p>
- 月减20-30斤,不反弹,是普通减肥产品效果的10倍
- </p>
- </div>
- </div>
- <div class="item">
- <img src="http://www.kuiyu.net/images/image6.jpg" />
- <div class="carousel-caption">
- <h4>
- <a target="_blank" href="http://www.kuiyu.net/tg/mb">可肤冰肌白</a>
- </h4>
- <p>
- 轻松一抹 亮白全身,7天炫出嫩白肌肤,缔造晶莹冰美人
- </p>
- </div>
- </div>
- <div class="item">
- <img src="http://www.kuiyu.net/images/image1.jpg" />
- <div class="carousel-caption">
- <h4>
- <a target="_blank" href="http://www.kuiyu.net/tg/cy">加入高佣金联盟</a>
- </h4>
- <p>
- 高佣金联盟是全国首家正规单品CPS平台,依托联盟内的优质产品、强大人气、流量和互动性,以及成熟的广告模式,为广大推广客提供各类高转化、高佣金产品,提供准确无误的订单跟踪、专业的客服服务,以达到推广收益最大化.
- </p>
- </div>
- </div>
- </div><a class="carousel-control left" href="#myCarousel" data-slide="prev"><em class="m-icon-big-swapleft m-icon-white"></em></a><a class="carousel-control right" href="#myCarousel" data-slide="next"><em class="m-icon-big-swapright m-icon-white"></em></a>
- </div>
- </div>
- <div class="span5">
- </div>
- </div>
- </div>
from:http://www.kuiyu.net/art-36.html