首页 > 代码库 > bootstrap

bootstrap

1.介绍:由Twiiter公司开始,最早移动设备优先,可以使自己的网页效果更加漂亮

2.使用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 101 Template</title>
   
  <!-- Bootstrap -->
  <link href="http://www.mamicode.com/css/bootstrap.min.css" rel="stylesheet">
   
  <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn‘t work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->
  </head>
  <body>
   
   
  <!-- jQuery (necessary for Bootstrap‘s JavaScript plugins) -->
  <script src="http://www.mamicode.com/css/jquery.min.js"></script>
  <!-- Include all compiled plugins (below), or include individual files as needed -->
  <script src="http://www.mamicode.com/js/bootstrap.min.js"></script>
  </body>
  </html>

3.引用字体图标glyphicons:写法:<div class=glyphicons glyphicons>

4.下拉菜单:dropdown:写法:

<div class="dropdown">
  <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">
    Dropdown
    <span class="caret"></span>
  </button>
  <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
    <li role="presentation"><a role="menuitem" tabindex="-1" href=http://www.mamicode.com/"#">Action</a></li>
    <li role="presentation"><a role="menuitem" tabindex="-1" href=http://www.mamicode.com/"#">Another action</a></li>
    <li role="presentation"><a role="menuitem" tabindex="-1" href=http://www.mamicode.com/"#">Something else here</a></li>
    <li role="presentation"><a role="menuitem" tabindex="-1" href=http://www.mamicode.com/"#">Separated link</a></li>
  </ul>
</div>

5.按钮组btn-group:写法:
<div class="btn-group" role="group" aria-label="...">
  <button type="button" class="btn btn-default">Left</button>
  <button type="button" class="btn btn-default">Middle</button>
  <button type="button" class="btn btn-default">Right</button>
</div>

6.按钮式下拉菜单写法:
<!-- Single button -->
<div class="btn-group">
  <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
    Action <span class="caret"></span>
  </button>
  <ul class="dropdown-menu" role="menu">
    <li><a href=http://www.mamicode.com/"#">Action</a></li>
    <li><a href=http://www.mamicode.com/"#">Another action</a></li>
    <li><a href=http://www.mamicode.com/"#">Something else here</a></li>
    <li class="divider"></li>
    <li><a href=http://www.mamicode.com/"#">Separated link</a></li>
  </ul>
</div>

7.输入框组:
<div class="input-group">
  <span class="input-group-addon" id="basic-addon1">@</span>
  <input type="text" class="form-control" placeholder="Username" aria-describedby="basic-addon1">
</div>

<div class="input-group">
  <input type="text" class="form-control" placeholder="Recipient‘s username" aria-describedby="basic-addon2">
  <span class="input-group-addon" id="basic-addon2">@example.com</span>
</div>

<div class="input-group">
  <span class="input-group-addon">$</span>
  <input type="text" class="form-control" aria-label="Amount (to the nearest dollar)">
  <span class="input-group-addon">.00</span>
</div>

8.进度条:1.不显示进度:
<div class="progress">
  <div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%;">
    <span class="sr-only">60% Complete</span>
  </div>
</div>  
2.显示进度:
<div class="progress">
  <div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%;">
    60%
  </div>
</div>

 

bootstrap