Bootstrap轮播图的使用和理解4

所属分类: 网络编程 / JavaScript 阅读数: 1036
收藏 0 赞 0 分享

本文实例为大家分享了Bootstrap轮播图的实现代码,供大家参考,具体内容如下

<!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="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
 <script src="//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 -->
 <!-- 控制 -->
 <!-- 向左滑动 -->
 <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>
 <!-- 向右滑动 -->
 <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", //鼠标悬停在轮播图上,是否停止滚动
  wrap:true, //
  keyboard:true //响应键盘事件
 });

 $("#prev").click(function(event) {
  $('.carousel').carousel('prev')// 周期上一个项目。
 });

 $("#next").click(function(event) {
  $('.carousel').carousel('next')// 周期到下一个项目。
 });;

 $("#pause").click(function(event) {
  $('.carousel').carousel('pause')// 从通过项目循环停止传送带。
 });;

 $("#start").click(function(event) {
  $('.carousel').carousel('cycle')// 通过传送带项目周期从左到右。
 });;

 $("#jump").click(function(event) {
  $('.carousel').carousel(1)// 循环传送带到一个特定的帧(0为主,类似于数组)。
 });;


 });
 </script>
 </body>
</html>

如果大家还想深入学习,可以点击这里进行学习,再为大家附3个精彩的专题:

Bootstrap学习教程

Bootstrap实战教程

Bootstrap Table使用教程

Bootstrap插件使用教程

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

更多精彩内容其他人还在看

Canvas实现放射线动画效果

本文主要分享了Canvas实现放射线动画的示例代码。具有很好的参考价值,下面跟着小编一起来看下吧
收藏 0 赞 0 分享

微信小程序 image组件binderror使用例子与js中的onerror区别

这篇文章主要介绍了微信小程序 image组件binderror使用例子与js中的onerror区别的相关资料,需要的朋友可以参考下
收藏 0 赞 0 分享

原生js轮播(仿慕课网)

本文主要分享了原生js实现仿慕课网的轮播效果。具有很好的参考价值,下面跟着小编一起来看下吧
收藏 0 赞 0 分享

Bootstrap table简单使用总结

这篇文章主要为大家总结了Bootstrap table的简单使用方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

微信小程序之MaterialDesign--input组件详解

本篇文章主要介绍了微信小程序之MaterialDesign--input组件详解,具有一定的参考价值,感兴趣的小伙伴们可以参考一下。
收藏 0 赞 0 分享

浅析javaScript中的浅拷贝和深拷贝

本篇文章主要介绍了浅析javaScript中的浅拷贝和深拷贝,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
收藏 0 赞 0 分享

js时间戳和c#时间戳互转方法(推荐)

下面小编就为大家带来一篇js时间戳和c#时间戳互转方法(推荐)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
收藏 0 赞 0 分享

Bootstrap模态框使用详解

这篇文章主要为大家详细介绍了Bootstrap模态框的使用方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
收藏 0 赞 0 分享

Jil,高效的json序列化和反序列化库

下面小编就为大家带来一篇Jil,高效的json序列化和反序列化库。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
收藏 0 赞 0 分享

BootStrap实现带关闭按钮功能

这篇文章主要介绍了BootStrap实现带关闭按钮功能,非常不错,具有参考借鉴价值,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多