---
# System prepended metadata

title: 2019-10-22 上課程式碼
tags: [前端程式設計, 108-1]

---

# 2019-10-22 上課程式碼

## 範例一

1. 增加中文字型
2. 增加 icon
3. 覆寫 bootstrap 原本樣式

* bootstrap.html

```htmlmixed=
<!DOCTYPE html>
<html lang="zh-TW">

<head>
    <meta charset="UTF-8 ">
    <meta name="viewport " content="width=device-width, initial-scale=1.0 ">
    <meta http-equiv="X-UA-Compatible " content="ie=edge ">
    <title>Bootstrap 練習</title>

    <!-- 引用 Bootstrap 的 CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

    <!-- 引用 Google 中文字型 -->
    <link href="https://fonts.googleapis.com/css?family=Noto+Sans+TC|Noto+Serif+TC&display=swap" rel="stylesheet">

    <!-- 引用 font-awesome ICON 的 CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.css" integrity="sha256-46qynGAkLSFpVbEBog43gvNhfrOj+BmwXdxFgVK/Kvc=" crossorigin="anonymous" />

    <!-- 引用自己定義的CSS -->
    <link rel="stylesheet" href="./css/bootstrap.css">
</head>

<body>

    <div class="container">

        <div class="jumbotron">
            <h1 class="display-4">前端程式設計</h1>
        </div>

        <div class="row">
            <div class="col">
                <button class="btn btn-primary btn-lg"><i class="fab fa-facebook-square"></i> Facebook</button>
                <button class="btn btn-success btn-lg"><i class="fab fa-line"></i> Line</button>
            </div>
        </div>

        <div class="row">
            <div class="col">
                <button class="btn btn-secondary"><i class="fas fa-volume-down"></i></button>
                <button class="btn btn-secondary"><i class="fas fa-volume-up"></i></button>
                <button class="btn btn-secondary"><i class="fas fa-volume-mute"></i></button>
            </div>
        </div>
    </div>

    <!-- 引用 Bootstrap 的 JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>

</html>
```

* bootstrap.css

```css=
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "Noto Sans TC", sans-serif;
}

.jumbotron {
    background-color: #3f65d0;
    color: white;
}
```

## 範例二

1. 增加 Carousel
2. 可自動換頁
3. 可設定換頁秒數
4. 請自行下載三張圖片分別取名為 `c1.jpg`, `c2.jpg`, `c3.jpg` 並且複製到 `img` 資料夾

* bootstrap.html

```htmlmixed=
<!DOCTYPE html>
<html lang="zh-TW">

<head>
    <meta charset="UTF-8 ">
    <meta name="viewport " content="width=device-width, initial-scale=1.0 ">
    <meta http-equiv="X-UA-Compatible " content="ie=edge ">
    <title>Bootstrap 練習</title>

    <!-- 引用 Bootstrap 的 CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

    <!-- 引用 Google 中文字型 -->
    <link href="https://fonts.googleapis.com/css?family=Noto+Sans+TC|Noto+Serif+TC&display=swap" rel="stylesheet">

    <!-- 引用 font-awesome ICON 的 CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.css" integrity="sha256-46qynGAkLSFpVbEBog43gvNhfrOj+BmwXdxFgVK/Kvc=" crossorigin="anonymous" />

    <!-- 引用自己定義的CSS -->
    <link rel="stylesheet" href="./css/bootstrap.css">
</head>

<body>

    <div class="container">

        <div class="jumbotron">
            <h1 class="display-4">前端程式設計</h1>
        </div>

        <div class="row">
            <div class="col">
                <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
                    <!-- 自動換頁 -->
                    <ol class="carousel-indicators">
                        <li data-target="#carouselExampleCaptions" data-slide-to="0" class="active"></li>
                        <li data-target="#carouselExampleCaptions" data-slide-to="1" class=""></li>
                        <li data-target="#carouselExampleCaptions" data-slide-to="2" class=""></li>
                    </ol>
                    <div class="carousel-inner">
                        <div class="carousel-item active" data-interval="2000">
                            <img src="./img/c1.jpg" class="d-block w-100" alt="...">
                        </div>
                        <div class="carousel-item" data-interval="2000">
                            <img src="./img/c2.jpg" class="d-block w-100" alt="...">
                        </div>
                        <div class="carousel-item" data-interval="2000">
                            <img src="./img/c3.jpg" class="d-block w-100" alt="...">
                        </div>
                    </div>
                    <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
                        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                        <span class="sr-only">Previous</span>
                    </a>
                    <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
                        <span class="carousel-control-next-icon" aria-hidden="true"></span>
                        <span class="sr-only">Next</span>
                    </a>
                </div>
            </div>
        </div>


        <div class="row">
            <div class="col">
                <button class="btn btn-primary btn-lg"><i class="fab fa-facebook-square"></i> Facebook</button>
                <button class="btn btn-success btn-lg"><i class="fab fa-line"></i> Line</button>
            </div>
        </div>

        <div class="row">
            <div class="col">
                <button class="btn btn-secondary"><i class="fas fa-volume-down"></i></button>
                <button class="btn btn-secondary"><i class="fas fa-volume-up"></i></button>
                <button class="btn btn-secondary"><i class="fas fa-volume-mute"></i></button>
            </div>
        </div>
    </div>

    <!-- 引用 Bootstrap 的 JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>

</html>
```

* bootstrap.css

```css=
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "Noto Sans TC", sans-serif;
}

.jumbotron {
    background-color: #3f65d0;
    color: white;
}
```

## 範例三

1. 增加導覽列

* bootstrap.html

```htmlmixed=
<!DOCTYPE html>
<html lang="zh-TW">

<head>
    <meta charset="UTF-8 ">
    <meta name="viewport " content="width=device-width, initial-scale=1.0 ">
    <meta http-equiv="X-UA-Compatible " content="ie=edge ">
    <title>Bootstrap 練習</title>

    <!-- 引用 Bootstrap 的 CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

    <!-- 引用 Google 中文字型 -->
    <link href="https://fonts.googleapis.com/css?family=Noto+Sans+TC|Noto+Serif+TC&display=swap" rel="stylesheet">

    <!-- 引用 font-awesome ICON 的 CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.css" integrity="sha256-46qynGAkLSFpVbEBog43gvNhfrOj+BmwXdxFgVK/Kvc=" crossorigin="anonymous" />

    <!-- 引用自己定義的CSS -->
    <link rel="stylesheet" href="./css/bootstrap.css">
</head>

<body>

    <!-- 導覽列 -->
    <nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark">
        <a class="navbar-brand" href="#"><i class="fab fa-html5"></i><i class="fab fa-css3-alt"></i><i class="fab fa-js"></i> 前端程式設計</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                  <span class="navbar-toggler-icon"></span>
                </button>

        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav mr-auto">
                <li class="nav-item active">
                    <a class="nav-link" href="#">首頁 <span class="sr-only">(current)</span></a>
                </li>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        課堂練習
                      </a>
                    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <a class="dropdown-item" href="./Emmet.html">Emmet 快速鍵</a>
                        <a class="dropdown-item" href="./table.html">Table 練習</a>
                        <a class="dropdown-item" href="./img.html">圖片練習</a>
                        <a class="dropdown-item" href="./text.html">span 練習</a>
                        <!-- <div class="dropdown-divider"></div> -->
                        <!-- <a class="dropdown-item" href="#">Something else here</a> -->
                    </div>
                </li>
            </ul>

        </div>
    </nav>

    <!-- 網頁內容 -->
    <div class="container">

        <!-- 標題 -->
        <div class="jumbotron">
            <h1 class="display-4">前端程式設計</h1>
        </div>

        <!-- 旋轉照片 -->
        <div class="row">
            <div class="col">
                <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
                    <!-- 自動換頁 -->
                    <ol class="carousel-indicators">
                        <li data-target="#carouselExampleCaptions" data-slide-to="0" class="active"></li>
                        <li data-target="#carouselExampleCaptions" data-slide-to="1" class=""></li>
                        <li data-target="#carouselExampleCaptions" data-slide-to="2" class=""></li>
                    </ol>
                    <div class="carousel-inner">
                        <div class="carousel-item active" data-interval="2000">
                            <img src="./img/c1.jpg" class="d-block w-100" alt="...">
                        </div>
                        <div class="carousel-item" data-interval="2000">
                            <img src="./img/c2.jpg" class="d-block w-100" alt="...">
                        </div>
                        <div class="carousel-item" data-interval="2000">
                            <img src="./img/c3.jpg" class="d-block w-100" alt="...">
                        </div>
                    </div>
                    <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
                        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                        <span class="sr-only">Previous</span>
                    </a>
                    <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
                        <span class="carousel-control-next-icon" aria-hidden="true"></span>
                        <span class="sr-only">Next</span>
                    </a>
                </div>
            </div>
        </div>

        <!-- 按扭 -->
        <div class="row">
            <div class="col">
                <button class="btn btn-primary btn-lg"><i class="fab fa-facebook-square"></i> Facebook</button>
                <button class="btn btn-success btn-lg"><i class="fab fa-line"></i> Line</button>
            </div>
        </div>

        <!-- 純 icon 按扭 -->
        <div class="row">
            <div class="col">
                <button class="btn btn-secondary"><i class="fas fa-volume-down"></i></button>
                <button class="btn btn-secondary"><i class="fas fa-volume-up"></i></button>
                <button class="btn btn-secondary"><i class="fas fa-volume-mute"></i></button>
            </div>
        </div>
    </div>

    <!-- 引用 Bootstrap 的 JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>

</html>
```

* bootstrap.css

```css
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "Noto Sans TC", sans-serif;
}

.jumbotron {
    background-color: #3f65d0;
    color: white;
}
```

###### tags: `前端程式設計` `108-1`