Bootstrap入門三:頁面排版


在Bootstrap中,頁面的排版都是從全局的概念上出發,定制了主體文本、強調文本、標題、Code風格、按鈕、表單、表格等格式,並運用CSS3的@font-face和偽元素一起實現了一套icon主題。

1.標題:

HTML 中的所有標題標簽,<h1><h6> 均可使用。另外,還提供了 .h1 到 .h6 類,為的是給內聯(inline)屬性的文本賦予標題的樣式。

<h1>h1. Bootstrap heading</h1>
<h2>h2. Bootstrap heading</h2>
<h3>h3. Bootstrap heading</h3>
<h4>h4. Bootstrap heading</h4>
<h5>h5. Bootstrap heading</h5>
<h6>h6. Bootstrap heading</h6>

 

在標題內還可以包含 標簽或賦予 .small 類的元素,可以用來標記副標題。

<h1>h1. Bootstrap heading <small>Secondary text</small></h1>
<h2>h2. Bootstrap heading <small>Secondary text</small></h2>
<h3>h3. Bootstrap heading <small>Secondary text</small></h3>
<h4>h4. Bootstrap heading <small>Secondary text</small></h4>
<h5>h5. Bootstrap heading <small>Secondary text</small></h5>
<h6>h6. Bootstrap heading <small>Secondary text</small></h6>

 

2.正文文本

Bootstrap 將全局 font-size 設置為 14px,line-height 設置為1.428(20px)。這些屬性直接賦予 <body> 元素和所有段落元素。另外,<p> (段落)元素還被設置了等於 1/2 行高(即 10px)的底部外邊距(margin)。顏色為#333333,背景色為白色。

通過添加 .lead 類可以讓段落突出顯示

<p class="lead">...</p>

 

使用 Less 工具構建
variables.less 文件中定義的兩個 Less 變量決定了排版尺寸:@font-size-base 和 @line-height-base。第一個變量定義了全局 font-size 基准,第二個變量是 line-height 基准。我們使用這些變量和一些簡單的公式計算出其它所有頁面元素的 margin、 padding 和 line-height。自定義這些變量即可改變 Bootstrap 的默認樣式。

3.內聯文本元素

1>.mark標簽

You can use the mark tag to <mark>highlight</mark> text.

 

2>.del標簽:被刪除的文本

<del>This line of text is meant to be treated as deleted text.</del>

 

3>.s標簽:無用的文本

<s>This line of text is meant to be treated as no longer accurate.</s>

 

4>.ins標簽:額外插入的文本

<ins>This line of text is meant to be treated as an addition to the document.</ins>

 

5>.u標簽:為文本添加下划線

<u>This line of text will render as underlined</u>

 

6>.small標簽:小號文本

對於不需要強調的inline或block類型的文本,使用 <small> 標簽包裹,其內的文本將被設置為父容器字體大小的 85%。標題元素中嵌套的 <small> 元素被設置不同的 font-size 。
你還可以為行內元素賦予 .small 類以代替任何 <small> 元素。

<small>This line of text is meant to be treated as fine print.</small>

 

7>. 文本強調:

.text-muted:淺灰色,提示;

.text-primary:淺藍色;

.text-warning:黃色,警告;
.text-error:紅色,錯誤;
.text-info:淺藍色,通知信息;
.text-success:淺綠色,成功;
Bootstrap用<small>標識不需要強調的文本,文本大小縮減到85%;
<strong>:強調文本,加粗顯示;
<em>:強調文本,斜體顯示;

在 HTML5 中可以放心使用 <b><i> 標簽。<b> 用於高亮單詞或短語,不帶有任何着重的意味;而 <i> 標簽主要用於發言、技術詞匯等。

4.文本對齊:

.text-left:左對齊;
.text-right:右對齊;
.text-center:居中對齊;
.text-justify
.text-nowrap

<p class="text-left">Left aligned text.</p>
<p class="text-center">Center aligned text.</p>
<p class="text-right">Right aligned text.</p>
<p class="text-justify">Justified text.</p>
<p class="text-nowrap">No wrap text.</p>

 

5.改變字母大小寫:

.text-lowercase:變小寫
.text-uppercase:變大寫
.text-capitalize:首字母大寫

<p class="text-lowercase">Lowercased text.</p>
<p class="text-uppercase">Uppercased text.</p>
<p class="text-capitalize">Capitalized text.</p>

 

6.縮略語 abbr:

當鼠標懸停在縮寫和縮寫詞上時就會顯示完整內容,Bootstrap 實現了對 HTML 的 <abbr> 元素的增強樣式。縮略語元素帶有 title 屬性,外觀表現為帶有較淺的虛線框,鼠標移至上面時會變成帶有“問號”的指針。如想看完整的內容可把鼠標懸停在縮略語上(對使用輔助技術的用戶也可見), 但需要包含 title 屬性。

基本縮略語

<abbr title="attribute">attr</abbr>

 

首字母縮略語
為縮略語添加 .initialism 類,可以讓 font-size 變得稍微小些。

<abbr title="HyperText Markup Language" class="initialism">HTML</abbr>

 

7.地址 address:

讓聯系信息以最接近日常使用的格式呈現。在每行結尾添加 <br> 可以保留需要的樣式。

<address>
  <strong>Twitter, Inc.</strong><br>
  795 Folsom Ave, Suite 600<br>
  San Francisco, CA 94107<br>
  <abbr title="Phone">P:</abbr> (123) 456-7890
</address>

<address>
  <strong>Full Name</strong><br>
  <a href="mailto:#">first.last@example.com</a>
</address>

 

8.引用風格 blockquote:

在你的文檔中引用其他來源的內容。

默認樣式的引用
將任何 HTML 元素包裹在 <blockquote> 中即可表現為引用樣式。對於直接引用,我們建議用 <p> 標簽。

<blockquote>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
</blockquote>

 

對於標准樣式的 <blockquote>,可以通過幾個簡單的變體就能改變風格和內容。

命名來源
添加 <footer> 用於標明引用來源。來源的名稱可以包裹進 <cite>標簽中。

<blockquote>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
  <footer>Someone famous in <cite title="http://www.quickcodes.net">App快速編碼</cite></footer>
</blockquote>

 

右對齊
通過賦予 .blockquote-reverse 類可以讓引用呈現內容右對齊的效果。

<blockquote class="blockquote-reverse">
  ...
</blockquote>

 

9.列表 ul ol dl:

.list-unstyled:移除默認的list-style樣式。注意,該樣式對li中嵌套的列表沒作用。

<ul class="list-unstyled">
    
  <li>Lorem ipsum dolor sit amet</li>
    <li>Consectetur adipiscing elit</li>
    <li>Integer molestie lorem at massa</li>
    <li>Facilisis in pretium nisl aliquet</li>
    <li>Nulla volutpat aliquam velit</li></ul>

 

.list-inline:讓列表項水平排列,且左右內邊距為5像素。如:<ol class="list-inline">

對於dl,可以用.dl-horizontal讓dt和dd的內容在一行上並列顯示;
通過 text-overflow 屬性,水平排列的描述列表將會截斷左側太長的短語。在較窄的視口(viewport)內,列表將變為默認堆疊排列的布局方式。

<dl class="dl-horizontal">
  <dt>...</dt>
  <dd>...</dd>
</dl>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM