亚洲区国产区激情区无码区,国产成人mv视频在线观看,国产A毛片AAAAAA,亚洲精品国产首次亮相在线

Bootstrap4 安裝使用

我們可以通過以下兩種方式來安裝 Bootstrap4:

  • 使用 Bootstrap 4  CDN。

  • 從官網(wǎng) getbootstrap.com 下載 Bootstrap 4。

Bootstrap 4 CDN

國內(nèi)推薦使用 Staticfile CDN 上的庫:

<!-- 新 Bootstrap4 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
 
<!-- jQuery文件。務(wù)必在bootstrap.min.js 之前引入 -->
<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
 
<!-- bootstrap.bundle.min.js 用于彈窗、提示、下拉菜單,包含了 popper.min.js -->
<script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
 
<!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
<script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>

注意:popper.min.js 用于設(shè)置彈窗、提示、下拉菜單,目前 bootstrap.bundle.min.js 已經(jīng)包含了 popper.min.js。

此外,你還可以使用以下的 CDN 服務(wù):

下載 Bootstrap 4

你可以去官網(wǎng) https://getbootstrap.com/ 下載 Bootstrap4 資源庫。

注:此外你還可以通過包的管理工具 npm、 gem、 composer 等來安裝:

npm install bootstrap@4.0.0-beta.2
gem 'bootstrap', '~> 4.0.0.beta2'
composer require twbs/bootstrap:4.0.0-beta.2

創(chuàng)建第一個 Bootstrap 4 頁面

1、添加 HTML5 doctype

Bootstrap 要求使用 HTML5 文件類型,所以需要添加 HTML5 doctype 聲明。

HTML5 doctype 在文檔頭部聲明,并設(shè)置對應(yīng)編碼:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8"> 
  </head>
</html>

移動設(shè)備優(yōu)先

為了讓 Bootstrap 開發(fā)的網(wǎng)站對移動設(shè)備友好,確保適當(dāng)?shù)睦L制和觸屏縮放,需要在網(wǎng)頁的 head 之中添加 viewport meta 標(biāo)簽,如下所示:

<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

width=device-width 表示寬度是設(shè)備屏幕的寬度。

initial-scale=1 表示初始的縮放比例。

shrink-to-fit=no 自動適應(yīng)手機屏幕的寬度。

容器類

Bootstrap 4 需要一個容器元素來包裹網(wǎng)站的內(nèi)容。

我們可以使用以下兩個容器類:

  • .container 類用于固定寬度并支持響應(yīng)式布局的容器。

  • .container-fluid 類用于 100% 寬度,占據(jù)全部視口(viewport)的容器。

兩個 Bootstrap 4 頁面

<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap 示例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
  <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
  <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
  <h1>我的第一個 Bootstrap 頁面</h1>
  <p>這是一些文本。</p> 
</div>
</body>
</html>
測試看看 ?/?

以下示例展示了占據(jù)全部視口(viewport)的容器。

<!DOCTYPE html>
<html>
<head>
  <title>Bootstrap 示例</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
  <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
  <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid">
  <h1>我的第一個 Bootstrap 頁面</h1>
  <p>使用了 .container-fluid,100% 寬度,占據(jù)全部視口(viewport)的容器。</p> 
</div>
</body>
</html>
測試看看 ?/?