本文实例讲解了Bootstrap实现图片轮播的详细代码,分享给大家供大家参考,具体内容如下
具体代码:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet"> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script> <style type="text/css"> img{ margin:0 auto; } </style> </head> <body> <div id="carousel-example-generic" data-ride="carousel"> <> <ol> <li data-target="#carousel-example-generic" data-slide-to="0"></li> <li data-target="#carousel-example-generic" data-slide-to="1"></li> <li data-target="#carousel-example-generic" data-slide-to="2"></li> </ol> <> <div role="listbox"> <div> <img src="images/lunbo1.jpg" height="266" width="800" alt="..."> <div> ... </div> </div> <div> <img src="images/lunbo2.jpg" height="266" width="800" alt="..."> <div> ... </div> </div> <div> <img src="images/lunbo3.jpg" height="266" width="800" alt="..."> <div> ... </div> </div> ... </div> <> <a href="#carousel-example-generic" role="button" data-slide="prev"> <span aria-hidden="true"></span> <span>Previous</span> </a> <a href="#carousel-example-generic" role="button" data-slide="next"> <span aria-hidden="true"></span> <span>Next</span> </a> </div> </body> </html>
效果
可选参数
data-ride=”carousel”:加上可以自动播放,不加点击后才会播放。 添加标题
标题写在 <div></div>之间
例如:
<div> <h3>果壳推书正式上线</h3> <p>好书分享、经验交流</p> </div>