Bootstrap,來(lái)自 Twitter,是目前最受歡迎的前端框架。Bootstrap 是基于 HTML、CSS、JAVASCRIPT 的,它簡(jiǎn)潔靈活,使得 Web 開發(fā)更加快捷。
學(xué)習(xí)要點(diǎn):
1.頁(yè)面排版
本節(jié)課我們主要學(xué)習(xí)一下 Bootstrap 全局 CSS 樣式中的排版樣式,包括了標(biāo)題、頁(yè)面主體、對(duì)齊、列表等常規(guī)內(nèi)容。
一.頁(yè)面排版
Bootstrap 提供了一些常規(guī)設(shè)計(jì)好的頁(yè)面排版的樣式供開發(fā)者使用。
1.頁(yè)面主體
Bootstrap 將全局 font-size 設(shè)置為 14px,line-height 行高設(shè)置為 1.428(即20px);<p>段落元素被設(shè)置等于 1/2 行高(即 10px);顏色被設(shè)置為#333。
//創(chuàng)建包含段落突出的文本<p>Bootstrap 框架</p><p class="lead">Bootstrap 框架</p><p>Bootstrap 框架</p><p>Bootstrap 框架</p><p>Bootstrap 框架</p>
2.標(biāo)題
//從 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 分別對(duì) h1 ~ h6 進(jìn)行了 CSS 樣式的重構(gòu),并且還支持普通內(nèi)聯(lián)元素定義 class=(.h1 ~ h6)來(lái)實(shí)現(xiàn)相同的功能。
//內(nèi)聯(lián)元素使用標(biāo)題字體<span class="h1">Bootstrap</span>
注:通過(guò) Firebug 查看元素還看到,字體顏色、字體樣式、行高均被固定了,從而保證了統(tǒng)一性,而原生的會(huì)根據(jù)系統(tǒng)內(nèi)置的首選字體決定,顏色是最黑色。
在 h1 ~ h6 元素之間,還可以嵌入一個(gè) small 元素作為副標(biāo)題,
//在標(biāo)題元素內(nèi)插入 small 元素<h1>Bootstrap 框架 <small>Bootstrap 小標(biāo)題</small></h1><h2>Bootstrap 框架 <small>Bootstrap 小標(biāo)題</small></h2><h3>Bootstrap 框架 <small>Bootstrap 小標(biāo)題</small></h3><h4>Bootstrap 框架 <small>Bootstrap 小標(biāo)題</small></h4><h5>Bootstrap 框架 <small>Bootstrap 小標(biāo)題</small></h5><h6>Bootstrap 框架 <small>Bootstrap 小標(biāo)題</small></h6>
通過(guò) Firebug 查看,我們發(fā)現(xiàn) h1 ~ h3 下 small 元素的大小只占父元素的 65%,那么通過(guò)計(jì)算(查看 Firebug 計(jì)算后的樣式), h1 ~ h3 下的 small 為 23.4px、 19.5px、 15.6px;h4 ~ h6 下 small 元素的大小只占父元素的 75% ,分別為:13.5px、10.5px、9px。在 h1 ~ h6 下的 small 樣式也進(jìn)行了改變,顏色變成淡灰色:#777,行高為 1,粗度為 400。
3.內(nèi)聯(lián)文本元素
//添加標(biāo)記,<mark>元素或.mark 類<p>Bootstrap<mark>框架</mark></p> //各種加線條的文本<del>Bootstrap 框架</del>//刪除的文本<s>Bootstrap 框架</s>//無(wú)用的文本<ins>Bootstrap 框架</ins>//插入的文本<u>Bootstrap 框架</u>//效果同上,下劃線文本 //各種強(qiáng)調(diào)的文本<small>Bootstrap 框架</small>//標(biāo)準(zhǔn)字號(hào)的 85%<strong>Bootstrap 框架</strong>//加粗 700<em>Bootstrap 框架</em>//傾斜
4.對(duì)齊
//設(shè)置文本對(duì)齊<p class="text-left">Bootstrap 框架</p>//居左<p class="text-center">Bootstrap 框架</p>//居中<p class="text-right">Bootstrap 框架</p>//居右<p class="text-justify">Bootstrap 框架</p>//兩端對(duì)齊,支持度不佳<p class="text-nowrap">Bootstrap 框架</p>//不換行
5.大小寫
//設(shè)置英文文本大小寫<p class="text-lowercase">Bootstrap 框架</p> //小寫<p class="text-uppercase">Bootstrap 框架</p> //大寫<p class="text-capitalize">Bootstrap 框架</p>//首字母大寫
6.縮略語(yǔ)
//縮略語(yǔ)Bootstrap<abbr style="margin: 0px; padding: 0px; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; color: rgb(0, 0, 0); font-family: tahoma, arial, 宋體;">//設(shè)置地址,去掉了傾斜,設(shè)置了行高,底部 20px<address> <strong>Twitter, Inc.</strong><br> 795 Folsom Ave, Suite 600<br> San Francisco, CA 94107<br> <abbr style="margin: 0px; padding: 0px; line-height: 25.2px; font-size: 14px; width: 660px; overflow: hidden; clear: both; color: rgb(0, 0, 0); font-family: tahoma, arial, 宋體;">//默認(rèn)樣式引用,增加了做邊線,設(shè)定了字體大小和內(nèi)外邊距<blockquote> Bootstrap 框架</blockquote> //反向<blockquote class="blockquote-reverse "> Bootstrap 框架</blockquote>
9.列表排版
//移出默認(rèn)樣式<ul class="list-unstyled"> <li>Bootstrap 框架</li> <li>Bootstrap 框架</li> <li>Bootstrap 框架</li> <li>Bootstrap 框架</li> <li>Bootstrap 框架</li></ul> //設(shè)置成內(nèi)聯(lián)<ul class="list-inline"> <li>Bootstrap 框架</li> <li>Bootstrap 框架</li> <li>Bootstrap 框架</li> <li>Bootstrap 框架</li> <li>Bootstrap 框架</li></ul> //水平排列描述列表<dl class="dl-horizontal"> <dt>Bootstrap</dt> <dd>Bootstrap 提供了一些常規(guī)設(shè)計(jì)好的頁(yè)面排版的樣式供開發(fā)者使用。</dd></dl>
10.代碼
//內(nèi)聯(lián)代碼<code><section></code> //用戶輸入press <kbd>ctrl + ,</kbd> //代碼塊<pre><p>Please input...</p></pre>
Bootstrap 還列舉了<var>表示標(biāo)記變量,<samp>表示程序輸出,只不過(guò)沒有重新復(fù)寫 CSS。
以上所述是小編給大家介紹的Bootstrap 頁(yè)面排版樣式的相關(guān)知識(shí),希望對(duì)對(duì)大家有所幫助!
新聞熱點(diǎn)
疑難解答