Bootstrap 使用了一些 HTML5 元素和 CSS 屬性,因此須要使用 HTML5 文檔類型。css
<!DOCTYPE html> <html lang="zh-CN"> ... </html>
爲了讓 Bootstrap 開發的網站對移動設備友好,確保適當的繪製和觸屏縮放,須要在網頁的 head 之中添加 viewport meta 標籤,以下所示:html
<meta name="viewport" content="width=device-width, //視口寬度爲設備寬度 initial-scale=1.0, //縮放程度 maximum-scale=1.0, //最大縮放級別(可選) user-scalable=no">//禁止頁面縮放(可選)
Bootstrap 使用 Normalize 來創建跨瀏覽器的一致性。Normalize.css 是一個很小的 CSS 文件,在 HTML 元素的默認樣式中提供了更好的跨瀏覽器一致性。git
關於佈局github
Bootstrap 提供了一套響應式、移動設備優先的流式網格系統,隨着屏幕或視口(viewport)尺寸的增長,系統會自動分爲最多12列。瀏覽器
img-responsive 用於img元素ide
container 用於包裹頁面上的內容的元素佈局
<div class="container"> <div class="row"> <div class="col-xs-6 col-md-2 col-md-offset-1"></div> <div class="col-xs-6 col-md-3"></div> <div class="col-xs-6 col-md-3"></div> <div class="col-xs-6 col-md-3"></div> </div> <div class="row">...</div> </div> <div class="container">.... <!--以上代碼在手機上就是兩行兩列,在電腦上是一行四列,其中第一列前面有空白,比其它列寬度小三分之一-->
//可以使用.col-md-push-* 和 .col-md-pull-* 這種類設定顯示,col-md-push-6按照我我的的理解,是在左面浮動了6列,而後再插入元素,col-md-pull-3則是在右邊浮動了3列,而後從右往左插入元素
@media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { ... }
//對於全部帶有 min-width: @screen-sm-min 的設備,若是屏幕的寬度小於 @screen-sm-max,則會進行一些處理。
關於排版字體
<small>本行內容是在標籤內</small><br> <strong>本行內容是在標籤內</strong><br> <em>本行內容是在標籤內,並呈現爲斜體</em><br> <p class="text-left">向左對齊文本</p> <p class="text-center">居中對齊文本</p> <p class="text-right">向右對齊文本</p> <p class="text-muted">本行內容是減弱的</p>灰 <p class="text-primary">本行內容帶有一個 primary class</p>藍 <p class="text-success">本行內容帶有一個 success class</p>綠 <p class="text-info">本行內容帶有一個 info class</p>深藍 <p class="text-warning">本行內容帶有一個 warning class</p>黃 <p class="text-danger">本行內容帶有一個 danger class</p>紅
<abbr title="World Wide Web">WWW</abbr><br> <abbr title="Real Simple Syndication" class="initialism">RSS</abbr>
<blockquote>這是一個帶有源標題的引用。<small>Someone famous in Source Title</small></blockquote>
list-unstyled用於未定義樣式列表ul,list-inline用於水平列表ul網站
關於表格spa
<div class="table-responsive"> <table class="table"> <caption>響應式表格佈局</caption> <thead> <tr> <th>產品</th> <th>付款日期</th> <th>狀態</th> </tr> </thead> <tbody> <tr> <td>產品1</td> <td>23/11/2013</td> <td>待發貨</td> </tr> </tbody> </table> </div>
關於表單
<input type="text" class="form-control" placeholder="文本輸入"/> <textarea class="form-control" rows="3"></textarea> <label for="name">可多選的選擇列表</label> <select multiple class="form-control"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select>
禁用的輸入框 input,若是您想要禁用一個輸入框 input,只須要簡單地添加 disabled 屬性
<input class="form-control" type="text" placeholder=""> <span class="help-block">一個較長的幫助文本塊,超過一行, 須要擴展到下一行。本實例中的幫助文本總共有兩行。</span>
關於按鈕
<button type="button" class="btn btn-default">默認按鈕</button> <!-- 提供額外的視覺效果,標識一組按鈕中的原始動做 --> <button type="button" class="btn btn-primary">原始按鈕</button> <!-- 表示一個成功的或積極的動做 --> <button type="button" class="btn btn-success">成功按鈕</button> <!-- 信息警告消息的上下文按鈕 --> <button type="button" class="btn btn-info">信息按鈕</button> <!-- 表示應謹慎採起的動做 --> <button type="button" class="btn btn-warning">警告按鈕</button> <!-- 表示一個危險的或潛在的負面動做 --> <button type="button" class="btn btn-danger">危險按鈕</button> <!-- 並不強調是一個按鈕,看起來像一個連接,但同時保持按鈕的行爲 --> <button type="button" class="btn btn-link">連接按鈕</button>
按鈕的大小
<p> <button type="button" class="btn btn-primary btn-lg"> 大的原始按鈕 </button> </p> <p> <button type="button" class="btn btn-primary"> 默認大小的原始按鈕 </button> </p> <p> <button type="button" class="btn btn-primary btn-sm"> 小的原始按鈕 </button> </p> <p> <button type="button" class="btn btn-primary btn-xs"> 特別小的原始按鈕 </button> </p> <p> <button type="button" class="btn btn-primary btn-lg btn-block"> 塊級的原始按鈕 </button> </p>
class爲active表示激活按鈕
class爲disabled表示禁用按鈕
在a和input上使用按鈕class也能弄成按鈕的樣子,可是考慮到跨瀏覽器的問題仍是在button上比較好
關於圖片
關於圖片的樣式除了以前提到的img-responsive用於圖片的自適應以外還有如下三個樣式
.img-rounded 圓角圖片
.img-circle 圓形圖片
.img-thumbnail 縮略圖功能
關於其它樣式類
關於不一樣設備