選單
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

什麼是 Bootstrap?


HTML

Bootstrap 是最流行的 CSS 框架,用於開發響應式和移動優先的網站。

Bootstrap 5 是 Bootstrap 的最新版本


Bootstrap 快速入門

Responsive Bootstrap Page

示例

<div class="bg-primary text-white p-5 text-center">
  <h1>我的第一個 Bootstrap 頁面</h1>
  <p>調整此頁面大小以檢視響應式效果!</p>
</div>

<div class="container-fluid">
  <div class="row">
    <div class="col-sm-4">
      <h2>London</h2>
      <p>London is the capital city of England.</p>
      <p>It is the most populous city in the United Kingdom,
      with a metropolitan area of over 13 million inhabitants.</p>
    </div>
    <div class="col-sm-4">
      <h2>Paris</h2>
      <p>Paris is the capital of France.</p>
      <p>The Paris area is one of the largest population centers in Europe,
      with more than 12 million inhabitants.</p>
    </div>
    <div class="col-sm-4">
      <h2>Tokyo</h2>
      <p>Tokyo is the capital of Japan.</p>
      <p>It is the center of the Greater Tokyo Area,
      and the most populous metropolitan area in the world.</p>
    </div>
  </div>
</div>
自己動手試一試 »

單擊“Try it Yourself”按鈕檢視其工作原理。



瀏覽器支援

Bootstrap 5 是 Bootstrap 的最新版本。

Bootstrap 5 支援所有主流瀏覽器,除了 Internet Explorer 11 及更早版本。

如果您需要支援 IE9 或 IE8,則必須使用 Bootstrap 3。


Bootstrap 容器

container 類是 Bootstrap 最重要的類之一。

它為 HTML 元素提供了邊距、填充、對齊等功能。

示例

<div class="container">
  <h1>This is a paragraph</h1>
  <p>This is a paragraph</p>
  <p>This is a paragraph</p>
  <p>This is a paragraph</p>
  <p>This is a paragraph</p>
</div>
自己動手試一試 »

Bootstrap 顏色

倫敦是英國人口最多的城市,都會區超過 900 萬居民。

倫敦是英國人口最多的城市,都會區超過 900 萬居民。

倫敦是英國人口最多的城市,都會區超過 900 萬居民。

倫敦是英國人口最多的城市,都會區超過 900 萬居民。

倫敦是英國人口最多的城市,都會區超過 900 萬居民。

倫敦是英國人口最多的城市,都會區超過 900 萬居民。

倫敦是英國人口最多的城市,都會區超過 900 萬居民。

示例

<div class="container bg-primary text-white p-4">
<p>London is the most populous city in the United Kingdom, with a metropolitan area of over 9 million inhabitants.</p>
</div>

<div class="container bg-success text-white p-4">
<p>London is the most populous city in the United Kingdom, with a metropolitan area of over 9 million inhabitants.</p>
</div>
自己動手試一試 »

Bootstrap 文字顏色

此文字被設為灰色。

此文字很重要。

此文字表示成功。

此文字代表一些資訊。

此文字代表警告。

此文字代表危險。

示例

<div class="container">
  <p class="text-muted">This text is muted.</p>
  <p class="text-primary">This text is important.</p>
  <p class="text-success">This text indicates success.</p>
  <p class="text-info">This text represents some information.</p>
  <p class="text-warning">This text represents a warning.</p>
  <p class="text-danger">This text represents danger.</p>
</div>
自己動手試一試 »

Bootstrap 列

所有裝置和螢幕寬度上的三個等寬列

示例

<div class="row">
  <div class="col">.col</div>
  <div class="col">.col</div>
  <div class="col">.col</div>
</div>
自己動手試一試 »

響應式列

三個等寬列,在小螢幕上堆疊在彼此之上

示例

<div class="row">
  <div class="col-sm-4">.col-sm-4</div>
  <div class="col-sm-4">.col-sm-4</div>
  <div class="col-sm-4">.col-sm-4</div>
</div>
自己動手試一試 »

Bootstrap 表格

一個帶邊框的斑馬條紋表

郵箱
John Doe john@example.com
Mary Moe mary@example.com
July Dooley july@example.com

示例

 <table class="table table-striped table-bordered">
  <thead>
    <tr>
      <th>Firstname</th>
      <th>Lastname</th>
      <th>Email</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>John</td>
      <td>Doe</td>
      <td>john@example.com</td>
    </tr>
    <tr>
      <td>Mary</td>
      <td>Moe</td>
      <td>mary@example.com</td>
    </tr>
    <tr>
      <td>July</td>
      <td>Dooley</td>
      <td>july@example.com</td>
    </tr>
  </tbody>
</table>
自己動手試一試 »

Bootstrap 警告

Bootstrap 提供了一種簡單的方法來建立預定義的警告訊息

Success!  This alert box indicates a successful or positive action.
Warning!  This alert box indicates a warning that might need attention.
Danger!  This alert box indicates a dangerous or potentially negative action.
Primary!  This alert box indicates an important action.

示例

<div class="alert alert-success">
  <strong>Success!</strong> Indicates a successful or positive action.
</div>
自己動手試一試 »

Bootstrap 按鈕

Bootstrap 提供不同風格的按鈕

示例

<button type="button" class="btn">Basic</button>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-secondary">Secondary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-info">Info</button>
<button type="button" class="btn btn-warning">Warning</button>
<button type="button" class="btn btn-danger">Danger</button>
<button type="button" class="btn btn-dark">Dark</button>
自己動手試一試 »

Bootstrap 卡片

Image

John Doe

Some example text some example text. John Doe is an architect and engineer.

檢視個人資料

示例

<div class="card" style="width:400px">
  <img src="img_avatar1.png" alt="Card image">
  <div class="card-body">
    <h4 class="card-title">John Doe</h4>
    <p class="card-text">一些示例文字。</p>
    <a href="#" class="btn btn-primary">檢視個人資料</a>
  </div>
</div>
自己動手試一試 »

完整的 Bootstrap 教程

這是對 Bootstrap 的簡短描述。

要獲取完整的 Bootstrap 5 教程,請訪問 W3Schools Bootstrap 5 教程


×

聯絡銷售

如果您想將 W3Schools 服務用於教育機構、團隊或企業,請傳送電子郵件給我們
sales@w3schools.com

報告錯誤

如果您想報告錯誤,或想提出建議,請傳送電子郵件給我們
help@w3schools.com

W3Schools 經過最佳化,旨在方便學習和培訓。示例可能經過簡化,以提高閱讀和學習體驗。教程、參考資料和示例會不斷審查,以避免錯誤,但我們無法保證所有內容的完全正確性。使用 W3Schools 即表示您已閱讀並接受我們的使用條款Cookie 和隱私政策

版權所有 1999-2024 Refsnes Data。保留所有權利。W3Schools 由 W3.CSS 提供支援