Bootstrap图片轮播效果详解

做个内心向阳的人。不忧伤,不心急。坚强向上,心向阳光。向前迈进。——松下幸之助抽出时间去学习,凡事从小做起,不怕单调和重复,长期的积累坚持,想不成功,也难。

导言

Bootstrap 轮播(Carousel)插件是一种灵活的响应式的向站点添加滑块的方式。除此之外,内容也是足够灵活的,可以是图像、内嵌框架、视频或者其他您想要放置的任何类型的内容。

示例

下面演示图片的轮播,使用bootstrap中的Carousel显示循环播放元素插件。

<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="..." alt="...">
   <div class="carousel-caption">
    ...
   </div>
  </div>
  <div class="item">
   <img src="..." alt="...">
   <div class="carousel-caption">
    ...
   </div>
  </div>
  ...
 </div>

 <!-- Controls -->
 <a class="left carousel-control" rel="nofollow noopener noreferrer" href="#carousel-example-generic" 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" rel="nofollow noopener noreferrer" 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>

在src中插入图片已为图片设置大小

还可以为其加上标题

<div class="item">
 <img src="..." alt="...">
 <div class="carousel-caption">
 <h3>...</h3>
 <p>...</p>
 </div>
</div>

参考

1.Bootstrap官网中文文档

2.菜鸟学堂Bootstrap好代码教程

以上就是Bootstrap图片轮播效果详解。信者不疑人,人亦信之。自疑者不信人,人亦疑之。更多关于Bootstrap图片轮播效果详解请关注haodaima.com其它相关文章!

您可能有感兴趣的文章
bootstrap select2 动态从后台Ajax动态获取数据的代码

MVC遇上bootstrap后的ajax表单验证

浅谈Bootstrap的DatePicker日期范围选择

bootstrap datepicker的基本使用好代码教程

Bootstrap 时间日历插件bootstrap-datetimepicker配置与应用小结