Peiyun Lee
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    ###### tags: `前端技能樹` # Bootstrap一下,快速建立響應式網站 ### 為什麼要使用Bootstrap? 現在的網頁為了能夠適應不同裝置,會進行響應式設計;並且大多考量到使用者經驗設計(UX,User Experience),使用一致性的設計元素。因此我們會需要針對每個元素去設定重複的樣式,以及在不同螢幕大小上的樣子。 **Bootstrap 是一套由 HTML、CSS 和 JavaScript 組成的工具**,讓你只要配合對應的 HTML 架構,加上 Bootstrap Class,就能夠**快速建立響應式網站,並且輕鬆設計出保有一致性的介面**,使網頁開發更容易。 ## 導入 Bootstrap 如何在專案中導入 Bootstrap?在[官網的安裝教學](https://getbootstrap.com/docs/5.1/getting-started/download/)有介紹各種導入方式,而其中一個方式就是透過 Bootstrap 的 CDN,直接從網路存取它的 CSS 和 JavaScript 的內容。 HTML ```html= <head> <!-- Bootstrap CSS 要放在其他自定義 CSS 前面--> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous"> </head> <body> ... <!-- Bootstrap JS --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script> </body> ``` ## 預設統一樣式 Bootstrap 會預先設定一些 HTML 元素基本的樣式,包括文字排版、圖片和表格等等。若這些樣式並非是你想要的,Bootstrap 也允許你使用 Sass 去自定義、擴展它的基本設定;或是你也可以直接透過建立 CSS 檔案,在 Bootstrap 框架的基礎上再去微調樣式。 ```html= <h1>Bootstrap h1</h1> <h2>Bootstrap h2</h2> <h3>Bootstrap h3</h3> ``` ![](https://i.imgur.com/FYolyLp.png) > Sass 是一種 CSS 預處理器(CSS Preprocessor),能夠以簡潔、維護性高的方式撰寫 CSS,提升開發效率。 ## 排版佈局 ### 斷點 (Breakpoints) Bootstrap中的斷點(Breakpoints)一樣是用於控制網頁在不同裝置上進行響應式的排版變化,採用的是 Mobile first 的設計方式,預設使用六個斷點如下: Breakpoint |Class infix|Dimensions -----------------|-----------|------ X-Small |None |<576px Small |sm |≥576px Medium |md |≥768px Large |lg |≥992px Extra large |xl |≥1200px Extra extra large|xxl |≥1400px ### 網格系統 (Grid system) 另外它還基於 Flexbox 建立了一套 Grid system,使用容器、行列來佈局,```row``` 包住 ```column``` ,每一行會有12欄,可以指定每個元素的欄位數量。 ```html= <div class="container"> <div class="row"> <!-- 兩個元素平分12欄 --> <div class="col">1</div> <div class="col">2</div> </div> <div class="row"> <!-- >=768px:6格 / <768px:8格 --> <div class="col-8 col-md-6">3</div> <!-- 平分剩下的欄位 --> <div class="col">4</div> <div class="col">5</div> </div> </div> ``` ![](https://i.imgur.com/GvThdss.gif) ## 通用類別 針對 CSS 樣式屬性設定出一些基本的模板,比如 Color、Border、Position ...等,讓我們能夠透過運用這些類別,快速設計出元素樣式,對於設計出一套一致性UI非常有用。 ### Color Bootstrap 預設的顏色樣式,可以在文字、背景中使用。 ![](https://i.imgur.com/qV5OnZ3.png) ```html= <!-- 設定文字是primary顏色 --> <p class="text-danger">...</p> ``` ### Spacing Bootstrap 預設的 ```margin```、```padding```,有基於基礎尺寸設定的幾種 ```size```。 ```html= <div class="mx-0">margin-left and margin-right are 0</div> <div class="pt-0">padding-top is 0</div> ``` ## 元件 Component 而 Bootstrap 最方便的是,它事先建立了一些網頁常用的UI元件,同時做好響應式設計,讓你透過使用它寫好的程式碼就可以快速建立出想要的元件。 ### Button ![](https://i.imgur.com/zVAFRIV.png) ```html <button type="button" class="btn btn-primary">Primary</button> ``` ### Navbar ```html= <nav class="navbar navbar-expand-sm 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="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarNav"> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Current page</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Page2</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Page3</a> </li> </ul> </div> </div> </nav> ``` ![](https://i.imgur.com/8Cf2Rms.gif) ## 小結 今天介紹了幾個 Bootstrap 的功能,除了排版佈局的部分建議你先進一步完整學習之外,其實剛開始使用不太需要清楚知道 Bootstrap 各個設定、組件的細節,**只要知道它大概提供了哪些功能,了解 Bootstrap 官方文件的架構後,依據你想要的組件、樣式去查詢套用方法**,基於框架再擴展自定義的樣式,就能很好的利用 Bootstrap 加速開發。 下一篇文章會來講到工程師必備的技能 — Git,運用它進行專案的版本控管,那我們就下章再見囉! 如果文章中有錯誤的地方,要麻煩各位大大不吝賜教;喜歡的話,也要記得幫我按讚訂閱❤️ ### 參考資料 - [Bootstrap - Document](https://getbootstrap.com/)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully