目錄
 前面的話
標題
【基本縮寫】
引用
列表
代码
首頁 web前端 html教學 使用Bootstrap排版

使用Bootstrap排版

Jun 22, 2017 am 11:12 AM
bootstrap 排版

 前面的話

  本文將詳細介紹Bootstrap中排版相關的內容

 

標題

【h】

##  HTML中所有的標題標籤,

 到 

 皆可使用

  預設情況下,從h1到h6的font-size如下所顯示

2em -> 1.5em -> 1.17em -> 1em -> 0.83em -> 0.67em;
登入後複製
  初始情況,1em = 16px,則換算如下 

32px -> 24px -> 18.72px -> 16px -> 13.28px -> 10.72px;
登入後複製
  Boostrap將h1-h6的字體大小font-size重新進行了設置,如下所示

36px -> 30px -> 24px -> 18px -> 14px -> 12px;
登入後複製
  另外,也提供了 

.h1 到 .h6 類,為的是給內聯( inline)屬性的文字賦予標題的樣式,除了display屬性不同外,其他屬性與<h1> 到<h6>樣式相同

h1,.h1{
    font-size: 36px;
    margin-top: 20px;
    margin-bottom: 10px;
    font-family: inherit;
    font-weight: 500;
    line-height: 1.1;
    color: inherit;
}
登入後複製
 【small】

#  在標題內還可以包含 

 標籤或賦予 .small 類別的元素,可用來標記副標題。 <small>標籤和.small類別的元素的樣式相同

h1 small,.h1 small, h1 .small, .h1 .small{
    font-size: 65%;
    font-weight: normal;
    line-height: 1;
    color: #777;
}
登入後複製
<h1>标题一 <small>副标题一</small></h1><h2>标题二 <small>副标题二</small></h2><h3>标题三 <small>副标题三</small></h3><h4>标题四 <small>副标题四</small></h4><h5>标题五 <small>副标题五</small></h5><h6>标题六 <small>副标题六</small></h6>
登入後複製


 

#段落

【body】

  預設情況下,頁面font-size為16px,行高line-height(chrome下)為1.334

#  Bootstrap 將全域 

font -size 設定為 14px,line-height 設定為 20px。這些屬性直接賦予  元素和所有段落元素

<span style="color: #000000;">body{
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 20px;
    color: #333;
    background-color: #fff;<br>   margin:0;
}</span>
登入後複製
【p】

  另外,

 (段落)元素也被設定了等於1/2 行高(即10px)的底部外邊距(margin)

p{
    margin: 0 0 10px;
}
登入後複製
【.lead】

  透過新增 

.lead 類別可以讓段落反白

.lead {
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 300;
    line-height: 1.4;
}
登入後複製
<p>一般内容</p><p class="lead">中心内容</p><p>一般内容</p>
登入後複製


 

#內聯文字

【標記文字】

  文字需要標記,使用標籤

mark, .mark {
    padding: .2em;
    background-color: #fcf8e3;
}
登入後複製
【刪除文字】

  對於被刪除的文字使用標籤

【無用文字】

  對於沒用的文字使用 標籤

#【插入文字】

  額外插入的文字使用 標籤

【帶下劃線的文字】

  為文字新增底線,使用 標籤

#【小號文本】

  對於不需要強調的inline或block類型的文本,使用 標籤包裹,其內的文本將被設定為父容器字體大小的85%。標題元素中嵌套的 元素被設定不同的 font-size 。

  也可以為行內元素賦予.small 類別以代替任何 元素

small, .small {
    font-size: 85%;
}
登入後複製
【著重】

  透過增加font-weight值強調一段文字

【斜體】

  用斜體強調一段文字

  [注意]在HTML5 中可以放心使用 標籤。 用於高亮單字或片語,不帶有任何著重的意味;而 標籤主要用於發言、技術詞彙等

<div>You can use the mark tag to <mark>highlight</mark> text.</div><div><del>This line of text is meant to be treated as deleted text.</del></div><div><s>This line of text is meant to be treated as no longer accurate.</s></div><div><ins>This line of text is meant to be treated as an addition to the document.</ins></div><div><u>This line of text will render as underlined</u></div><div><small>This line of text is meant to be treated as fine print.</small></div><div><strong>rendered as bold text</strong></div><div><em>rendered as italicized text</em></div>
登入後複製



對齊

  透過文字對齊類,可以簡單方便的將文字重新對齊

.text-left {
    text-align: left;
}
.text-center {
    text-align: center;
}
.text-right {
    text-align: right;
}
.text-justify {
    text-align: justify;
}
.text-nowrap {
    white-space: 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>
登入後複製

 大小寫

  透過這幾個類別可以改變文字的大小寫

.text-lowercase {
    text-transform: lowercase;
}
.text-uppercase {
    text-transform: uppercase;
}
.text-capitalize {
    text-transform: capitalize;
}
登入後複製

#

<p class="text-lowercase">Lowercased text.</p>
<p class="text-uppercase">Uppercased text.</p>
<p class="text-capitalize">Capitalized text.</p>
登入後複製

 
縮寫
#  當滑鼠懸停在縮寫和縮寫詞上時就會顯示完整內容,Bootstrap 實現了對HTML 的 


 元素的增強樣式。縮寫元素帶有 

title

 屬性,外觀表現為具有較淺的虛線框,滑鼠移至上面時會變成帶有「問號」的指標。如想看完整的內容可把滑鼠懸停在縮寫上(對使用輔助技術的使用者也可見), 但需要包含title 屬性

【基本縮寫】

abbr[title], abbr[data-original-title] {
    cursor: help;
    border-bottom: 1px dotted #777;
}
登入後複製
【縮寫】
  為縮寫添加 
.initialism
 類,可以讓font-size 變得稍微小一點
###
.initialism {
    font-size: 90%;
    text-transform: uppercase;
}
登入後複製
## ####
<abbr title="attribute">attr</abbr>
<abbr title="HyperText Markup Language" class="initialism">HTML</abbr>
登入後複製
############### ######位址######  讓聯絡資訊以最接近日常使用的格式呈現。在每行結尾加入 ###
### 可以保留所需的樣式######
address {
    margin-bottom: 20px;
    font-style: normal;
    line-height: 1.42857143;
}
登入後複製
######
<address>
  <strong>Twitter, Inc.</strong><br>
  1355 Market Street, Suite 900<br>
  San Francisco, CA 94103<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>
登入後複製
###


 

引用

【默认样式的引用】 

  将任何 HTML 元素包裹在

中即可表现为引用样式。对于直接引用,建议用

标签

blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
}
登入後複製
<blockquote>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
</blockquote>
登入後複製


【多种引用样式】

  对于标准样式的

,可以通过几个简单的变体就能改变风格和内容

  1、命名来源

  添加

用于标明引用来源。来源的名称可以包裹进 标签中

<blockquote>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
  <footer>Someone famous in <cite title="Source Title">Source Title</cite></footer>
</blockquote>
登入後複製

  2、另一种展示风格

  通过赋予 .blockquote-reverse 类可以让引用呈现内容右对齐的效果

<blockquote class="blockquote-reverse">
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
  <footer>Someone famous in <cite title="Source Title">Source Title</cite></footer>
</blockquote>
登入後複製
.blockquote-reverse, blockquote.pull-right {
    padding-right: 15px;
    padding-left: 0;
    text-align: right;
    border-right: 5px solid #eee;
    border-left: 0;
}
登入後複製


 

列表

【无序列表】

  排列顺序无关紧要的一列元素 

ul, ol {
    margin-top: 0;
    margin-bottom: 10px;
登入後複製
<ul>
  <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<ul>
      <li>Phasellus iaculis neque</li>
      <li>Purus sodales ultricies</li>
      <li>Vestibulum laoreet porttitor sem</li>
      <li>Ac tristique libero volutpat at</li>
    </ul>
  </li>
  <li>Faucibus porta lacus fringilla vel</li>
  <li>Aenean sit amet erat nunc</li>
  <li>Eget porttitor lorem</li>
</ul>
登入後複製


【有序列表】

  顺序至关重要的一组元素。 

<ol>
  <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>
  <li>Faucibus porta lacus fringilla vel</li>
  <li>Aenean sit amet erat nunc</li>
  <li>Eget porttitor lorem</li>
</ol>
登入後複製


【无样式列表】

  移除了默认的 list-style 样式和左侧外边距的一组元素(只针对直接子元素)。这是针对直接子元素的,也就是说,你需要对所有嵌套的列表都添加这个类才能具有同样的样式 

.list-unstyled {
    padding-left: 0;
    list-style: none;
}
登入後複製
<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<ul>
      <li>Phasellus iaculis neque</li>
      <li>Purus sodales ultricies</li>
      <li>Vestibulum laoreet porttitor sem</li>
      <li>Ac tristique libero volutpat at</li>
    </ul>
  </li>
  <li>Faucibus porta lacus fringilla vel</li>
  <li>Aenean sit amet erat nunc</li>
  <li>Eget porttitor lorem</li>
</ul>
登入後複製


【内联列表】

  通过设置 display: inline-block; 并添加少量的内边距(padding),将所有元素放置于同一行 

.list-inline {
    padding-left: 0;
    margin-left: -5px;
    list-style: none;
}
登入後複製
<ul class="list-inline">
  <li>Lorem ipsum</li>
  <li>Phasellus iaculis</li>
  <li>Nulla volutpat</li>
</ul>
登入後複製


【描述】 

  带有描述的短语列表。

dl {
    margin-top: 0;
    margin-bottom: 20px;
}
dt {
    font-weight: bold;
}
dt, dd {
    line-height: 1.42857143;
}
dd {
    margin-left: 0;
}
登入後複製
<dl>
  <dt>Description lists</dt>
  <dd>A description list is perfect for defining terms.</dd>
  <dt>Euismod</dt>
  <dd>Vestibulum id ligula porta felis euismod semper eget lacinia odio sem nec elit.</dd>
  <dd>Donec id elit non mi porta gravida at eget metus.</dd>
  <dt>Malesuada porta</dt>
  <dd>Etiam porta sem malesuada magna mollis euismod.</dd>
</dl>
登入後複製


【水平排列的描述】

  .dl-horizontal 可以让

内的短语及其描述排在一行。开始是像
的默认样式堆叠在一起,随着导航条逐渐展开而排列在一行

.dl-horizontal dt {float: left;
    width: 160px;
    overflow: hidden;
    clear: left;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dl-horizontal dd {
    margin-left: 180px;
}
登入後複製
<dl class="dl-horizontal">
  <dt>Description lists</dt>
  <dd>A description list is perfect for defining terms.</dd>
  <dt>Euismod</dt>
  <dd>Vestibulum id ligula porta felis euismod semper eget lacinia odio sem nec elit.</dd>
  <dd>Donec id elit non mi porta gravida at eget metus.</dd>
  <dt>Malesuada porta</dt>
  <dd>Etiam porta sem malesuada magna mollis euismod.</dd>
  <dt>Felis euismod semper eget lacinia</dt>
  <dd>Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</dd>
</dl>
登入後複製


 

代码

【内联代码】

   通过 标签包裹内联样式的代码片段。</p> <div class="cnblogs_code"><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">code {     padding: 2px 4px;     font-size: 90%;     color: #c7254e;     background-color: #f9f2f4;     border-radius: 4px; }</pre><div class="contentsignin">登入後複製</div></div></div> <p>【用户输入】</p> <p>  通过 <kbd> 标签标记用户通过键盘输入的内容。</p> <div class="cnblogs_code"><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">kbd {     padding: 2px 4px;     font-size: 90%;     color: #fff;     background-color: #333;     border-radius: 3px;-webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .25);     box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .25); }</pre><div class="contentsignin">登入後複製</div></div></div> <p>【代码块】</p> <p>  多行代码可以使用 <pre class="brush:php;toolbar:false"> 标签。为了正确的展示代码,注意将尖括号做转义处理。&lt;/p&gt; &lt;div class=&quot;cnblogs_code&quot;&gt;&lt;div class=&quot;code&quot; style=&quot;position:relative; padding:0px; margin:0px;&quot;&gt;&lt;pre class=&quot;brush:php;toolbar:false&quot;&gt;pre {     display: block;     padding: 9.5px;     margin: 0 0 10px;     font-size: 13px;     line-height: 1.42857143;     color: #333;     word-break: break-all;     word-wrap: break-word;     background-color: #f5f5f5;     border: 1px solid #ccc;     border-radius: 4px; }</pre><div class="contentsignin">登入後複製</div></div></div> <p>  还可以使用 <code>.pre-scrollable 类,其作用是设置 max-height 为 350px ,并在垂直方向展示滚动条。

.pre-scrollable {
    max-height: 340px;
    overflow-y: scroll;
}
登入後複製

【变量】

  通过 标签标记变量

【程序输出】

  通过 标签来标记程序输出的内容

<div>For example, <code>&lt;section&gt;</code> should be wrapped as inline.
</div>
<div>To switch directories, type <kbd>cd</kbd> followed by the name of the directory.<br>
    To edit settings, press <kbd><kbd>ctrl</kbd> + <kbd>,</kbd></kbd>
</div>
<div>
    <pre class="brush:php;toolbar:false">&lt;p&gt;Sample text here...&lt;/p&gt;
    
&lt;p&gt;Sample text here...&lt;/p&gt;
    y = mx + b
    This text is meant to be treated as sample output from a computer program.
登入後複製


 

以上是使用Bootstrap排版的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

熱門話題

Java教學
1677
14
CakePHP 教程
1431
52
Laravel 教程
1333
25
PHP教程
1278
29
C# 教程
1257
24
vue中怎麼用bootstrap vue中怎麼用bootstrap Apr 07, 2025 pm 11:33 PM

在 Vue.js 中使用 Bootstrap 分為五個步驟:安裝 Bootstrap。在 main.js 中導入 Bootstrap。直接在模板中使用 Bootstrap 組件。可選:自定義樣式。可選:使用插件。

bootstrap搜索欄怎麼獲取 bootstrap搜索欄怎麼獲取 Apr 07, 2025 pm 03:33 PM

如何使用 Bootstrap 獲取搜索欄的值:確定搜索欄的 ID 或名稱。使用 JavaScript 獲取 DOM 元素。獲取元素的值。執行所需的操作。

bootstrap垂直居中怎麼弄 bootstrap垂直居中怎麼弄 Apr 07, 2025 pm 03:21 PM

使用 Bootstrap 實現垂直居中:flexbox 法:使用 d-flex、justify-content-center 和 align-items-center 類,將元素置於 flexbox 容器內。 align-items-center 類法:對於不支持 flexbox 的瀏覽器,使用 align-items-center 類,前提是父元素具有已定義的高度。

bootstrap怎麼插入圖片 bootstrap怎麼插入圖片 Apr 07, 2025 pm 03:30 PM

在 Bootstrap 中插入圖片有以下幾種方法:直接插入圖片,使用 HTML 的 img 標籤。使用 Bootstrap 圖像組件,可以提供響應式圖片和更多樣式。設置圖片大小,使用 img-fluid 類可以使圖片自適應。設置邊框,使用 img-bordered 類。設置圓角,使用 img-rounded 類。設置陰影,使用 shadow 類。調整圖片大小和位置,使用 CSS 樣式。使用背景圖片,使用 background-image CSS 屬性。

bootstrap怎麼寫分割線 bootstrap怎麼寫分割線 Apr 07, 2025 pm 03:12 PM

創建 Bootstrap 分割線有兩種方法:使用 標籤,可創建水平分割線。使用 CSS border 屬性,可創建自定義樣式的分割線。

bootstrap怎麼設置框架 bootstrap怎麼設置框架 Apr 07, 2025 pm 03:27 PM

要設置 Bootstrap 框架,需要按照以下步驟:1. 通過 CDN 引用 Bootstrap 文件;2. 下載文件並將其託管在自己的服務器上;3. 在 HTML 中包含 Bootstrap 文件;4. 根據需要編譯 Sass/Less;5. 導入定製文件(可選)。設置完成後,即可使用 Bootstrap 的網格系統、組件和样式創建響應式網站和應用程序。

bootstrap按鈕怎麼用 bootstrap按鈕怎麼用 Apr 07, 2025 pm 03:09 PM

如何使用 Bootstrap 按鈕?引入 Bootstrap CSS創建按鈕元素並添加 Bootstrap 按鈕類添加按鈕文本

bootstrap怎麼調整大小 bootstrap怎麼調整大小 Apr 07, 2025 pm 03:18 PM

要調整 Bootstrap 中元素大小,可以使用尺寸類,具體包括:調整寬度:.col-、.w-、.mw-調整高度:.h-、.min-h-、.max-h-

See all articles