Bootstrap,來自Twitter,是目前最受歡迎的前端框架。 Bootstrap 是基於HTML、CSS、JAVASCRIPT 的,它簡潔靈活,使得Web 開發更加快捷。
學習要點:
1.頁面排版
本節課我們主要學習一下Bootstrap 全局CSS 樣式中的排版樣式,包括了標題、頁面主體、對齊、列表等常規內容。
一.頁面排版
Bootstrap 提供了一些常規設計好的頁面排版的樣式供開發者使用。
1.頁面主體
Bootstrap 將全局font-size 設置為14px,line-height 行高設置為1.428(即20px);<p>段落元素被設置等於1/2 行高(即10px);顏色被設置為#333。
//創建包含段落突出的文本<p>Bootstrap 框架</p><p>Bootstrap 框架</p><p>Bootstrap 框架</p><p>Bootstrap 框架</p><p>Bootstrap 框架</p>
2.標題
//從h1 到h6<h1>Bootstrap 框架</h1>//36px<h2>Bootstrap 框架</h2>//30px<h3>Bootstrap 框架</h3>//24px<h4>Bootstrap 框架</h4>//18px<h5>Bootstrap 框架</h5>//14px<h6>Bootstrap 框架</h6>//12px
我們從Firebug 查看元素了解到, Bootstrap 分別對h1 ~ h6 進行了CSS 樣式的重構,並且還支持普通內聯元素定義class=(.h1 ~ h6)來實現相同的功能。
//內聯元素使用標題字體<span>Bootstrap</span>
注:通過Firebug 查看元素還看到,字體顏色、字體樣式、行高均被固定了,從而保證了統一性,而原生的會根據系統內置的首選字體決定,顏色是最黑色。
在h1 ~ h6 元素之間,還可以嵌入一個small 元素作為副標題,
//在標題元素內插入small 元素<h1>Bootstrap 框架<small>Bootstrap 小標題</small></h1><h2>Bootstrap 框架<small>Bootstrap 小標題</small></h2><h3>Bootstrap 框架<small>Bootstrap 小標題</small></h3><h4>Bootstrap 框架<small>Bootstrap 小標題</small></h4><h5>Bootstrap 框架<small>Bootstrap 小標題</small></h5><h6>Bootstrap 框架<small>Bootstrap 小標題</small></h6>
通過Firebug 查看,我們發現h1 ~ h3 下small 元素的大小只佔父元素的65%,那麼通過計算(查看Firebug 計算後的樣式), h1 ~ h3 下的small 為23.4px、 19.5px、 15.6px;h4 ~ h6 下small 元素的大小只佔父元素的75% ,分別為:13.5px、10.5px、9px。在h1 ~ h6 下的small 樣式也進行了改變,顏色變成淡灰色:#777,行高為1,粗度為400。
3.內聯文本元素
//添加標記,<mark>元素或.mark 類<p>Bootstrap<mark>框架</mark></p> //各種加線條的文本<del>Bootstrap 框架</del>//刪除的文本<s>Bootstrap 框架</s>//無用的文本<ins>Bootstrap 框架</ins>//插入的文本<u>Bootstrap 框架</u>//效果同上,下劃線文本//各種強調的文本<small>Bootstrap 框架</small>//標準字號的85%<strong>Bootstrap 框架</strong>//加粗700<em>Bootstrap 框架</em>//傾斜
4.對齊
//設置文本對齊<p>Bootstrap 框架</p>//居左<p>Bootstrap 框架</p>//居中<p>Bootstrap 框架</p>//居右<p>Bootstrap 框架</p>//兩端對齊,支持度不佳<p>Bootstrap 框架</p>//不換行
5.大小寫
//設置英文文本大小寫<p>Bootstrap 框架</p> //小寫<p>Bootstrap 框架</p> //大寫<p>Bootstrap 框架</p>//首字母大寫
6.縮略語
//縮略語Bootstrap<abbr>框架</abbr>
7.地址文本
//設置地址,去掉了傾斜,設置了行高,底部20px<address> <strong>Twitter, Inc.</strong><br> 795 Folsom Ave, Suite 600<br> San Francisco, CA 94107<br> <abbr>P:</abbr> (123) 456-7890</address>
8.引用文本
//默認樣式引用,增加了做邊線,設定了字體大小和內外邊距<blockquote> Bootstrap 框架</blockquote> //反向<blockquote> Bootstrap 框架</blockquote>
9.列表排版
//移出默認樣式<ul> <li>Bootstrap 框架</li> <li>Bootstrap 框架</li> <li>Bootstrap 框架</li> <li>Bootstrap 框架</li> <li>Bootstrap 框架</li></ul> //設置成內聯<ul> <li>Bootstrap 框架</li> <li>Bootstrap 框架</li> <li>Bootstrap 框架</li> <li>Bootstrap 框架</li> <li>Bootstrap 框架</li></ul> //水平排列描述列表<dl> <dt>Bootstrap</dt> <dd>Bootstrap 提供了一些常規設計好的頁面排版的樣式供開發者使用。 </dd></dl>
10.代碼
//內聯代碼<code><section></code> //用戶輸入press <kbd>ctrl + ,</kbd> //代碼塊<pre><p>Please input...</p></pre>
Bootstrap 還列舉了<var>表示標記變量,<samp>表示程序輸出,只不過沒有重新復寫CSS。
以上所述是小編給大家介紹的Bootstrap 頁面排版樣式的相關知識,希望對對大家有所幫助!