1、bootStrap组件
无数可复用的组件,包括字体图标、下拉菜单、导航、警告框、弹出框等更多功能。
2、字体图标
①不要和其他图标混合使用
②只能对内容为空的元素起作用
3、下拉菜单
1 <div class="dropdown"> 2 <button class="btn btn-default dropdown-toggle" 3 type="button" 4 data-toggle="dropdown"> 5 DropDown 6 <span class="caret"></span> 7 </button> 8 <ul class="dropdown-menu"> 9 <li class="dropdown-header">健身</li> 10 <li><a href="#">哑铃</a></li> 11 <li><a href="#">仰卧起坐</a></li> 12 <li role="separator" class="divider"></li> 13 <li class="dropdown-header">跑步</li> 14 <li><a href="#">半马</a></li> 15 <li class="disabled"><a href="#">全马</a></li> 16 <li><a href="#">5km</a></li> 17 <li><a href="#">10km</a></li> 18 </ul>
4、按钮组
1 <div class="container"> 2 <div class="btn-toolbar"> 3 <div class="btn-group btn-group-vertical" role="group"> 4 <button type="button" class="btn btn-default">Left</button> 5 <button type="button" class="btn btn-default">Middle</button> 6 <button type="button" class="btn btn-default">Right</button> 7 </div> 8 <div class="btn-group btn-group" role="group"> 9 <button type="button" class="btn btn-default">Left</button> 10 <button type="button" class="btn btn-default">Middle</button> 11 <button type="button" class="btn btn-default">Right</button> 12 </div> 13 </div> 14 <hr/> 15 <div class="btn-group btn-group-lg" role="group"> 16 <button type="button" class="btn btn-default">Left</button> 17 <button type="button" class="btn btn-default">Middle</button> 18 <button type="button" class="btn btn-default">Right</button> 19 </div> 20 <br/> 21 <br/> 22 23 <div class="btn-group btn-group-sm" role="group"> 24 <button type="button" class="btn btn-default">Left</button> 25 <button type="button" class="btn btn-default">Middle</button> 26 <button type="button" class="btn btn-default">Right</button> 27 </div> 28 <br/> 29 <br/> 30 31 <div class="btn-group btn-group-xs" role="group"> 32 <button type="button" class="btn btn-default">Left</button> 33 <button type="button" class="btn btn-default">Middle</button> 34 <button type="button" class="btn btn-default">Right</button> 35 </div> 36 </div> 37 <div class="btn-group btn-group-justified" role="group" aria-label="..."> 38 <div class="btn-group" role="group"> 39 <button type="button" class="btn btn-default">Left</button> 40 </div> 41 <div class="btn-group" role="group"> 42 <button type="button" class="btn btn-default">Middle</button> 43 </div> 44 <div class="btn-group" role="group"> 45 <button type="button" class="btn btn-default">Right</button> 46 </div> 47 </div>
5、下拉式按钮菜单
1 ddiv class="btn-group"> 2 <!-- Single button --> 3 <div class="btn-group"> 4 <button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown"> 5 Action <span class="caret"></span> 6 </button> 7 <ul class="dropdown-menu"> 8 <li> <a href="#">1</a></li> 9 <li> <a href="#">2</a></li> 10 <li> <a href="#">3</a></li> 11 <!--<li role="separator"class="divider"></li>--> 12 13 <li> <a href="#">4</a></li> 14 </ul> 15 </div> 16 <!-- Single button --> 17 <div class="btn-group"> 18 <button type="button" class="btn btn-warning dropdown-toggle" data-toggle="dropdown"> 19 Action <span class="caret"></span> 20 </button> 21 <ul class="dropdown-menu"> 22 <li> <a href="#">1</a></li> 23 <li> <a href="#">2</a></li> 24 <li> <a href="#">3</a></li> 25 <li> <a href="#">4</a></li> 26 </ul> 27 </div> 28 <!-- Single button --> 29 <div class="btn-group"> 30 <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown"> 31 Action <span class="caret"></span> 32 </button> 33 <ul class="dropdown-menu"> 34 <li> <a href="#">1</a></li> 35 <li> <a href="#">2</a></li> 36 <li> <a href="#">3</a></li> 37 <li> <a href="#">4</a></li> 38 </ul> 39 </div> 40 <!-- Single button --> 41 <div class="btn-group"> 42 <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> 43 Action <span class="caret"></span> 44 </button> 45 <ul class="dropdown-menu"> 46 <li> <a href="#">1</a></li> 47 <li> <a href="#">2</a></li> 48 <li> <a href="#">3</a></li> 49 <li> <a href="#">4</a></li> 50 </ul> 51 </div> 52 </div>
给父元素添加 .dropup
类就能使触发的下拉菜单朝上方打开。
6、输入框组
为 .input-group
赋予.input-group-addon
类,可以给 .form-control
的前面或后面添加额外的元素。
<div class="input-group"> <input type="text" class="form-control" placeholder="kunyashaw"> <span class="input-group-addon">@</span> <input type="text" class="form-control" placeholder="tedu.cn"> </div> <div class="input-group"> <span class="input-group-addon">htt://</span> <input type="text" class="form-control" placeholder="kunyashaw"> <span class="input-group-addon">@tedu.cn</span> </div>
7、导航
1 <ul class="nav nav-tabs"> 2 <li role="presentation" class="active"><a href="#">home</a></li> 3 <li role="presentation"><a href="http://www.baidu.com">bai du</a></li> 4 <li role="presentation"><a href="http://www.qq.com">qq</a></li> 5 </ul> 6 <br> 7 <br> 8 <br> 9 <ul class="nav nav-pills"> 10 <li role="presentation"><a href="#">home</a></li> 11 <li role="presentation" class="active"><a href="http://www.baidu.com">bai du</a></li> 12 <li role="presentation"><a href="http://www.qq.com">qq</a></li> 13 </ul> 14 15 <br> 16 <hr> 17 <ul class="nav nav-pills nav-stacked"> 18 <li role="presentation"><a href="#">home</a></li> 19 <li role="presentation " class="disabled"><a href="http://www.baidu.com">bai du</a></li> 20 <li role="presentation" class="active"><a href="http://www.qq.com">qq</a></li> 21 </ul> 22 <hr> 23 <br> 24 <ul class="nav nav-pills "> 25 <li role="presentation"><a href="#">home</a></li> 26 <li role="presentation " class="active"><a href="http://www.baidu.com">bai du</a></li> 27 <li role="presentation" class="dropdown"> 28 <a class="dropdown dropdown-toggle" data-toggle="dropdown"> 29 hello <span class="caret"></span> 30 </a> 31 <ul class="dropdown-menu"> 32 <li >1</li> 33 <li >2</li> 34 <li >3</li> 35 </ul> 36 </li> 37 </ul>
8、导航条
1 <div class="container"> 2 <ui class="nav navbar-nav"> 3 <li role=" presentation" class="active"><a href="#">hello</a></li> 4 <li role="presentation"><a href="#">world</a></li> 5 <li role="presentation"><a href="#">automan</a></li> 6 <li role="presentation" class="dropdown "> 7 <a type="button" class="dropdown dropdown-toggle" data-toggle="dropdown"> 8 autoMan<span class="caret"></span> 9 </a> 10 <ul class="dropdown-menu"> 11 <li>hello</li> 12 <li>hello</li> 13 <li>hello</li> 14 </ul> 15 </li> 16 </ui> 17 <form class=" navbar-left navbar-form" role="search"> 18 <div class="form-group"> 19 <input class="form-control" placeholder="search"> 20 </div> 21 <button type="button" class="btn btn-default">submit</button> 22 </form> 23 24 <ui class="nav navbar-nav navbar-right"> 25 <li role="presentation"><a href="#">normalLi</a></li> 26 <li role="presentation" class="dropdown "> 27 <a type="button" class="dropdown dropdown-toggle" data-toggle="dropdown"> 28 autoMan<span class="caret"></span> 29 </a> 30 <ul class="dropdown-menu"> 31 <li>hello</li> 32 <li>hello</li> 33 <li>hello</li> 34 </ul> 35 </li> 36 </ui> 37 38 </div>
通过添加 .navbar-inverse
类可以改变导航条的外观
.navbar-fixed-top
类可以让导航条固定在顶部,
.navbar-fixed-bottom
类可以让导航条固定在底部,
使用 .navbar-link
类可以让链接有正确的默认颜色和反色设置。
<form class="navbar-form navbar-left" role="search"> <div class="form-group"> <input type="text" class="form-control" placeholder="Search"> </div> <button type="submit" class="btn btn-default">Submit</button> </form>
9、面包屑导航
<ol class="breadcrumb"> <li><a href="#">Home</a></li> <li><a href="#">Library</a></li> <li class="active">Data</li> </ol>
10、分页
1 <nav> 2 <ul class="pagination pagination-lg"> 3 <li class="disabled"><a href="#"><span>«</span></a></li> 4 <li><a href="#">1</a></li> 5 <li><a href="#">2</a></li> 6 <li><a href="#">3</a></li> 7 <li><a href="#">4</a></li> 8 <li><a href="#">5</a></li> 9 <li><a href="#"><span>»</span></a></li> 10 </ul> 11 <br/> 12 <br/> 13 <br/> 14 <ul class="pagination pagination-sm"> 15 <li class="disabled"><a href="#"><span>«</span></a></li> 16 <li><a href="#">1</a></li> 17 <li><a href="#">2</a></li> 18 <li><a href="#">3</a></li> 19 <li><a href="#">4</a></li> 20 <li><a href="#">5</a></li> 21 <li><a href="#"><span>»</span></a></li> 22 </ul> 23 </nav> 24 25 <nav> 26 <ul class="pager"> 27 <li><a href="#">Previous</a></li> 28 <li><a href="#">Next</a></li> 29 </ul> 30 </nav>
11、标签、徽章
1 <div class="container"> 2 <!--标签--> 3 <h1>鱼香肉丝<span class="label label-default">Hot</span></h1> 4 5 <h2>宫保鸡丁<span class="label label-success">Spicy</span></h2> 6 7 <h3>肉夹馍<span class="label label-warning">Hot</span></h3> 8 9 <h3>肉夹馍<span class="label label-danger">Hot</span></h3> 10 11 <!--徽章--> 12 <a href="#"> baidu <span class="badge">New</span></a> 13 <button type="button" class="btn btn-primary"> 14 Messages 15 <span class="badge">4</span> 16 </button> 17 18 <!-- 胶囊导航--> 19 <ui class="nav nav-pills" role="tablist"> 20 <li role="presentation" class="active"><a href="#">Home<span class="badge">42</span></a></li> 21 <li role="presentation"><a href="#">Profile</a></li> 22 <li role="presentation"><a href="#">Messages<span class="badge">3</span></a></li> 23 </ui> 24 </div>
12、巨幕
1 <!---index.html----> 2 <div class=" container" > 3 <div class="jumbotron jumubg" > 4 <h1> hell world </h1> 5 <p> 6 This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured 7 content or information. 8 Learn more 9 </p> 10 <button class="btn btn-primary" type="button">Learn More<a href="#"></a></button> 11 </div> 12 </div> 13 14 15 <!--demo.css----> 16 17 .jumubg { 18 background: url("zzl.jpg"); 19 1000px; 20 height: 600px; 21 }
13、页头
1 <div class=" container" > 2 <!--页头组件能够为 h1 标签增加适当的空间,并且与页面的其他部分形成一定的分隔。--> 3 <!--它支持 h1 标签内内嵌 small 元素的默认效果,还支持大部分其他组件(需要增加一些额外的样式)--> 4 <div class="page-header"> 5 <h1>Example page header <small>Subtext for header</small></h1> 6 </div> 7 </div>
14、缩略图
1 <div class="container"> 2 <div class="row"> 3 <div class="col-md-3"> 4 <div class="thumbnail"> 5 <img src="zzl.jpg" width="100px" height="200px"> 6 <div class="caption"> 7 <h3>Label</h3> 8 <p> 9 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. 10 </p> 11 <button type="button" role="button" class="btn btn-primary">ok</button> 12 <button type="button" role="button" class="btn btn-danger">cancel</button> 13 </div> 14 </div> 15 </div> 16 17 <div class="col-md-3"> 18 <div class="thumbnail"> 19 <img src="zzl.jpg" width="100px" height="200"px> 20 <div class="caption"> 21 <h3>Label</h3> 22 <p> 23 Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at 24 eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit. 25 </p> 26 <button type="button" role="button" class="btn btn-primary">ok</button> 27 <button type="button" role="button" class="btn btn-default">cancel</button> 28 </div> 29 </div> 30 </div> 31 32 </div> 33 </div>
15、警告框
可以设置警告框可以点击:
务必给 <button>
元素添加 data-dismiss="alert"
属性
可以在警告框中设置链接:
用 .alert-link
工具类,可以为链接设置与当前警告框相符的颜色。
1 <div class="container"> 2 <div class="alert alert-success">success</div> 3 <div class="alert alert-info">information</div> 4 <div class="alert alert-warning">warning plz contact: 5 <a href="wss.jpg" class="alert-link"> 6 wss 7 </a> 8 </div> 9 <div class="alert alert-danger alert-dismissable" role="alert"> 10 <button type="button" class="close" data-dismiss="alert"> 11 <span>×</span> 12 </button> 13 Danger 14 </div> 15 16 </div>
16、进度条
1 <div class="container"> 2 <div class="progress"> 3 <div class="progress-bar" role="progressbar" style=" 40%"> 4 <span>40%</span> 5 </div> 6 </div> 7 <div class="progress"> 8 <div class="progress-bar" role="progressbar" style=" 100%"> 9 <span>100%</span> 10 </div> 11 </div> 12 <p>设置最小宽度为5em min- 5em"</p> 13 <div class="progress"> 14 <div class="progress-bar" role="progressbar" style=" 1%;min- 5em"> 15 <span>1%</span> 16 </div> 17 </div> 18 19 <div class="progress"> 20 <div class="progress-bar progress-bar-danger" role="progressbar" style="20%;"> 21 <span>20%</span> 22 </div> 23 </div> 24 <div class="progress"> 25 <div class="progress-bar progress-bar-info" role="progressbar" style="40%;"> 26 <span>40%</span> 27 </div> 28 </div> 29 <div class="progress"> 30 <div class="progress-bar progress-bar-warning" role="progressbar" style="80%;"> 31 <span>80%</span> 32 </div> 33 </div> 34 <div class="progress"> 35 <div class="progress-bar progress-bar-success" role="progressbar" style="100%;"> 36 <span>100%</span> 37 </div> 38 </div> 39 <p> 40 通过渐变( progress-bar-striped)可以为进度条创建条纹效果,IE9 及更低版本不支持。 41 </p> 42 <div class="progress"> 43 <div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" style="80%;"> 44 <span>80%</span> 45 </div> 46 </div> 47 48 <p> 49 为 .progress-bar-striped 添加 .active 类,使其呈现出由右向左运动的动画效果。IE9 及更低版本的浏览器不支持。--> 50 </p> 51 <div class="progress"> 52 <div class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" style="80%;"> 53 <span>80%</span> 54 </div> 55 </div> 56 </div>
17、媒体对象
1 <div class="container"> 2 <div class="media"> 3 <div class="media-left media-middle"> 4 <img src="wss.jpg" class="img-rounded" width="50" height="80"> 5 </div> 6 <div class="media-body"> 7 8 <div class="media-heading"> 9 <h1>sport</h1> 10 </div> 11 <div class="media-right"> 12 <p> 13 hello worlCras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin 14 commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.d 15 hello worlCras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin 16 </p> 17 </div> 18 </div> 19 </div> 20 21 22 <div class="media"> 23 <div class="media-body"> 24 <div class="media-heading"> 25 <h1>Sport Utlitied Vehicle</h1> 26 27 <div class="media-left"> 28 <p> 29 hello worlCras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante 30 sollicitudin 31 commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.d 32 commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.d 33 </p> 34 </div> 35 </div> 36 </div> 37 <div class="media-right media-middle"> 38 <img src="zzl.jpg" class="img-rounded" width="50" height="80"> 39 </div> 40 </div> 41 </div>
19、列表组
1 <div class="container"> 2 3 <ui class="list-group"> 4 <li class="list-group-item"> hello</li> 5 <li class="list-group-item"> hello</li> 6 </ui> 7 <br> 8 <br> 9 <!-- 徽章组合 10 <li class="list-group-item active"> 11 hel1qasdlo <span class="badge">12</span> 12 </li>--> 13 <ui class="list-group"> 14 <li class="list-group-item active"> 15 hel1qasdlo <span class="badge">12</span> 16 </li> 17 <li class="list-group-item"> 18 hzadsfkadsjf <span class="badge">100</span> 19 </li> 20 21 </ui> 22 <br> 23 <br> 24 <!-- 超链接组合 <a class="list-group-item active" href="#" >kkk</a>--> 25 <ui class="list-group"> 26 <a class="list-group-item " href="#">baidu</a> 27 <a class="list-group-item " href="#">google</a> 28 </ui> 29 <br> 30 <br> 31 32 <div class="list-group"> 33 <button role="button" class=" list-group-item list-group-item-danger">hello1</button> 34 <button role="button" class=" list-group-item list-group-item-success">hello2</button> 35 <!-- 为 .list-group-item 添加 .disabled 类可以让单个条目显示为灰色,表现出被禁用的效果--> 36 <button role="button" class=" list-group-item disabled">hello3</button> 37 </div> 38 39 <div class="list-group"> 40 <a href="#" class="list-group-item"> 41 <h4 class="list-group-item-heading">List group item heading</h4> 42 <p class="list-group-item-text"> 为 .list-group-item 添加 .disabled 类可以让单个条目显示为灰色,表现出被禁用的效果</p> 43 </a> 44 <a href="#" class="list-group-item"> 45 <h4 class="list-group-item-heading">List group item heading</h4> 46 <p class="list-group-item-text"> 为 .list-group-item 添加 .disabled 类可以让单个条目显示为灰色,表现出被禁用的效果</p> 47 </a> 48 </div> 49 50 </div>
20、面板
默认的 .panel
组件所做的只是设置基本的边框(border)和内补(padding)来包含内容。
通过 .panel-heading
可以很简单地为面板加入一个标题容器。你也可以通过添加设置了 .panel-title
类的 <h1>
-<h6>
标签,添加一个预定义样式的标题。为了给链接设置合适的颜色,务必将链接放到带有 .panel-title
类的标题标签内。
把按钮或次要的文本放入 .panel-footer
容器内。注意面版的脚注不会从情境效果中继承颜色,因为他们并不是主要内容。
像其他组件一样,可以简单地通过加入有情境效果的状态类,给特定的内容使用更针对特定情境的面版。
1 <div class="container"> 2 <div class="panel"> 3 hello world 4 </div> 5 6 <br> 7 <br> 8 9 <div class="panel panel-primary"> 10 <div class="panel-heading"> 11 Panel Without a head 12 </div> 13 <div class="panel-body"> 14 I am Panel Body 15 </div> 16 </div> 17 18 <br> 19 <br> 20 21 <div class="panel panel-warning"> 22 <div class="panel-heading"> 23 <h1 class="panel-title"> 24 Panel With a head 25 </h1> 26 </div> 27 <div class="panel-body"> 28 I am Panel Body 29 </div> 30 </div> 31 32 <br> 33 <br> 34 35 <div class="panel panel-success"> 36 <div class="panel-body"> 37 I am Panel Body 38 </div> 39 <div class="panel-footer"> 40 <h1 class="panel-title"> 41 Panel With a footer 42 </h1> 43 </div> 44 </div> 45 </div>
表格
1 <!--制作一个带表格的面板--> 2 <div class="panel panel-info"> 3 <br> 4 <br> 5 6 <div class="panel-heading"> 7 <h1 class="panel-title"> 8 2016年3月最新消息 9 </h1> 10 </div> 11 <div class="panel-body"> 12 <p>恭喜企业新三板上市,并成功拿下100000亿融资,开创史上最高融资记录,下表为具体数据</p> 13 </div> 14 <table class="table table-bordered"> 15 <thead> 16 <td>name</td> 17 <td>age</td> 18 <td>province</td> 19 </thead> 20 <tr> 21 <td>18</td> 22 <td>kunyashaw</td> 23 <td>Mars</td> 24 </tr> 25 <tr> 26 <td>20</td> 27 <td>wss</td> 28 <td>China</td> 29 </tr> 30 <tr> 31 <td>10</td> 32 <td>wzs</td> 33 <td>Julpiter</td> 34 </tr> 35 36 </table> 37 38 <br> 39 <br> 40 41 <div class="panel-heading"> 42 <h1 class="panel-title"> 43 2016年3月最新消息 44 </h1> 45 </div> 46 <table class="table table-bordered"> 47 <thead> 48 <td>name</td> 49 <td>age</td> 50 <td>province</td> 51 </thead> 52 <tr> 53 <td>18</td> 54 <td>kunyashaw</td> 55 <td>Mars</td> 56 </tr> 57 <tr> 58 <td>20</td> 59 <td>wss</td> 60 <td>China</td> 61 </tr> 62 <tr> 63 <td>10</td> 64 <td>wzs</td> 65 <td>Julpiter</td> 66 </tr> 67 68 </table> 69 70 </div>
1 <--带面板的列表--> 2 <div class="container"> 3 <div class="panel panel-warning"> 4 <div class="panel-heading"> 5 <h1> 6 特卖会,请注意 7 </h1> 8 </div> 9 10 <div class="panel-body"> 11 <strong>特卖产品列表请见下表:</strong> 12 </div> 13 14 <ul class="list-group"> 15 <li class="list-group-item">男士外套</li> 16 <li class="list-group-item">女士手套</li> 17 <li class="list-group-item">儿童棉衣</li> 18 </ul> 19 20 </div> 21 </div>
21、Well
1 <div class="container"> 2 <!-- 把 Well 用在元素上,能有嵌入(inset)的的简单效果。--> 3 <br> 4 <br> 5 <div class="well well-lg"> 6 Look, I'm in a well 7 </div> 8 <br> 9 <br> 10 <div class="well well"> 11 Look, I'm in a well 12 </div> 13 <br> 14 <br> 15 <div class="well well-sm"> 16 Look, I'm in a well 17 </div> 18 </div>