iT邦幫忙

2021 iThome 鐵人賽

DAY 17
0
Modern Web

33歲轉職者的前端筆記系列 第 17

33歲轉職者的前端筆記-DAY 17 Bootstrap 介紹及使用方法

什麼是 Bootstrap ?

  • 是一個框架系統
  • 是一個UI的框架 (framework)
  • 已提供現成可供使用的語法
  • 可快速方便完成網站增加開發效率

使用方法

1.放雲端
2.下載下來
nav bar 使用方式:
第一步:首頁點以下圖 等同於點上方的 Docs

https://ithelp.ithome.com.tw/upload/images/20210916/20120789Gx9qzAkkCQ.jpg

第二步:點右邊

https://ithelp.ithome.com.tw/upload/images/20210916/20120789wEjh8IloEY.jpg

第三步: 複制以下程式碼到vs code

https://ithelp.ithome.com.tw/upload/images/20210916/20120789UyTEX5sOcF.jpg

第四步:點右邊選單的 例如 nav bar

https://ithelp.ithome.com.tw/upload/images/20210916/20120789Y5Uyek1uDC.jpg

第五步: 複制程式碼到vs code的body 裡面

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Navbar</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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 me-auto mb-2 mb-lg-0">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="#">Home</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Link</a>
        </li>
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            Dropdown
          </a>
          <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
            <li><a class="dropdown-item" href="#">Action</a></li>
            <li><a class="dropdown-item" href="#">Another action</a></li>
            <li><hr class="dropdown-divider"></li>
            <li><a class="dropdown-item" href="#">Something else here</a></li>
          </ul>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
        </li>
      </ul>
      <form class="d-flex">
        <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
        <button class="btn btn-outline-success" type="submit">Search</button>
      </form>
    </div>
  </div>
</nav>

初始使用的必要步驟:
1.點Gettin started
2.點下方Introduction
3.複製Starter template 裡的code 到vs code的body

<!doctype html>
<html lang="en">

<head>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <!-- Bootstrap CSS -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet"
    integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">

  <title>Hello, world!</title>
</head>

<body>
  <h1>Hello, world!</h1>
  <div class="container">
    <div class="row">
      <div class="col-4">
        <img src="https://picsum.photos/300/200?random=10" class="w-100">
      </div>
      <div class="col-4">
        <img src="https://picsum.photos/300/200?random=10" class="w-100">
      </div>
      <div class="col-4">
        <img src="https://picsum.photos/300/200?random=10" class="w-100">
      </div>

    </div>
  </div>

  <!-- Optional JavaScript; choose one of the two! -->

  <!-- Option 1: Bootstrap Bundle with Popper -->
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js"
    integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4"
    crossorigin="anonymous"></script>

  <!-- Option 2: Separate Popper and Bootstrap JS -->
  <!--
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.min.js" integrity="sha384-Atwg2Pkwv9vp0ygtn1JAojH0nYbwNJLPhwyoVbhoPwBhjQPR5VtM2+xf0Uwh9KtT" crossorigin="anonymous"></script>
    -->
</body>

</html>

上一篇
33歲轉職者的前端筆記-DAY 16 使用 jQuery 寫出動畫效果
下一篇
33歲轉職者的前端筆記-DAY 18 練習寫一個自我介紹產生器
系列文
33歲轉職者的前端筆記30

1 則留言

0
max19960419
iT邦新手 5 級 ‧ 2021-09-17 09:45:38

Bootstrap

a841722 iT邦新手 5 級 ‧ 2021-09-17 18:12:29 檢舉

感謝提醒

我要留言

立即登入留言