欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Bootstrap学习笔记 轮播(Carousel)插件

程序员文章站 2023-11-10 20:15:10
bootstrap 轮播(carousel)插件是一种灵活的响应式的向站点添加滑块的方式。除此之外,内容也是足够灵活的,可以是图像、内嵌框架、视频或者其他您想要放置的任何类...

bootstrap 轮播(carousel)插件是一种灵活的响应式的向站点添加滑块的方式。除此之外,内容也是足够灵活的,可以是图像、内嵌框架、视频或者其他您想要放置的任何类型的内容。如果您想要单独引用该插件的功能,那么您需要引用 carousel.js,或者bootstrap.js 或压缩版的 bootstrap.min.js。

<!doctype html> 
<html> 
 <head> 
 <title>bootstrap 轮播(carousel)插件</title> 
 <meta charset="utf-8"> 
 <link rel="stylesheet" href="css/bootstrap.min.css" rel="external nofollow" > 
 <link rel="stylesheet" href="css/carousel.css" rel="external nofollow" > 
 <script src="js/jquery.min.js"></script> 
 <script src="js/bootstrap.min.js"></script> 
 </head> 
 <body> 
 <!-- carousel 
 ================================================== --> 
 <div id="mycarousel" class="carousel slide" data-ride="carousel"> 
 <!-- indicators --> 
 <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" role="listbox"> 
 <div class="item active"> 
 <img class="first-slide" src="http://localhost:8020/bootstrap/img/slide1.png" alt="first slide"> 
 <div class="container"> 
 <div class="carousel-caption"> 
 <h1>example headline.</h1> 
 <p> 
 note: if you're viewing this page via a <code> 
  file://</code> 
 url, the "next" and "previous" glyphicon buttons on the left and right might not load/display properly due to web browser security rules. 
 </p> 
 <p> 
 <a class="btn btn-lg btn-primary" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" role="button">sign up today</a> 
 </p> 
 </div> 
 </div> 
 </div> 
 <div class="item"> 
 <img class="second-slide" src="data:image/gif;base64,r0lgodlhaqabaiaaahd3dwaaach5baaaaaaalaaaaaabaaeaaaicraeaow==" alt="second slide"> 
 <div class="container"> 
 <div class="carousel-caption"> 
 <h1>another example headline.</h1> 
 <p> 
 cras justo odio, dapibus ac facilisis in, egestas eget quam. donec id elit non mi porta gravida at eget metus. nullam id dolor id nibh ultricies vehicula ut id elit. 
 </p> 
 <p> 
 <a class="btn btn-lg btn-primary" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" role="button">learn more</a> 
 </p> 
 </div> 
 </div> 
 </div> 
 <div class="item"> 
 <img class="third-slide" src="data:image/gif;base64,r0lgodlhaqabaiaaahd3dwaaach5baaaaaaalaaaaaabaaeaaaicraeaow==" alt="third slide"> 
 <div class="container"> 
 <div class="carousel-caption"> 
 <h1>one more for good measure.</h1> 
 <p> 
 cras justo odio, dapibus ac facilisis in, egestas eget quam. donec id elit non mi porta gravida at eget metus. nullam id dolor id nibh ultricies vehicula ut id elit. 
 </p> 
 <p> 
 <a class="btn btn-lg btn-primary" href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" role="button">browse gallery</a> 
 </p> 
 </div> 
 </div> 
 </div> 
 </div> 
 <!--左前进右后退--> 
 <a class="left carousel-control" href="#mycarousel" rel="external nofollow" rel="external nofollow" 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" href="#mycarousel" rel="external nofollow" rel="external nofollow" role="button" data-slide="next"> 
 <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> 
 <span class="sr-only">next</span> 
 </a> 
 </div> 
 <!-- /.carousel --> 
 </body> 
</html> 

注意:

<img class="second-slide" src="data:image/gif;base64,r0lgodlhaqabaiaaahd3dwaaach5baaaaaaalaaaaaabaaeaaaicraeaow==" alt="second slide">

  data格式的url最直接的好处是,这些url原本会引起一个新的网络访问,因为那里是一个网页的地址,现在不会有新的网络访问了,因为现在这里是网页的内容。这样做,会减少服务器的负载,当然同时也增加了当前网页的大小。所以对“小”数据特别有好处。

效果图

Bootstrap学习笔记 轮播(Carousel)插件

bootstrap组件专题大家可以参考下:

//www.jb51.net/special/708.htm

以上所述是小编给大家介绍的bootstrap学习笔记 轮播(carousel)插件,希望对大家有所帮助