Wanting
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
      • 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 No publishing access yet

        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.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        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 New
      • Engagement control
      • Make a copy
      • 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 Note Insights Versions and GitHub Sync Sharing URL Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Engagement control Make a copy 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 No publishing access yet

    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.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Bootstrap 5 格線系統 ![](https://i.imgur.com/L5wt3ej.png) ## 格線系統 - 減輕 magic number 出現 * 格線系統的組成:column(欄)、gutter(間距,可以是margin或padding) * [960 grid,以前解析度都是 1024](https://960.gs/demo.html) 12個column(欄)11個gutter(間距),因為12這個數字是可以被2.3.4.6整除,即一列兩欄,一列三欄,一列四欄等,其gutter以margin下去推 * [BS4 layoutit](https://www.layoutit.com/build) 其gutter以padding下去推 > 常見總欄數是 12 ## [BS5 格線系統](https://bootstrap5.hexschool.com/docs/5.0/layout/grid/)原理 * 排版三劍客: .container、.row、.col 1~12 * .container * .container 固定寬度 * .container-fluid 滿版 * .row * no-gutters:不需要 gutters * 名言 1:.col- 的外層只能是 .row * 名言 2:.row 裡面第一層只能是 .col-(就像ul裡面第一層只能是li,tr裡面第一層只能是td) * 名言 3:網頁內容與元件請放在 .col- 裡面 >正確範例 ```htmlmixed= <div class="container"> <div class="row"> <div class="col-4"></div> <div class="col-5"></div> </div> <div class="row"> <div class="col-4"></div> <div class="col-5"></div> </div> </div> ``` >錯誤範例(row下面第一層只能是col,h2部分就錯了) ```htmlmixed= <div class="container"> <div class="row"> <div class="h2">標題</div> <div class="col-3">左邊選單</div> <div class="col-8"></div> </div> </div> ``` ![](https://i.imgur.com/VWS9WS3.png) 即不是我們想要的效果,標題和左邊選單沒有在同一列裡呈現 >若col放超過12,會往下排 ```htmlmixed= <div class="container"> <div class="row"> <div class="col-4 green">左邊選單</div> <div class="col-4 green">標題</div> <div class="col-4 green">標題</div> <div class="col-4 green">標題</div> <div class="col-4 green">標題</div> <div class="col-4 green">標題</div> </div> </div> ``` ![](https://i.imgur.com/MqNGVFi.png) 因為row本身也是應用[flex](https://courses.hexschool.com/courses/html/lectures/14727004)的效果去做出來的 flex-wrap:wrap即內容變多時,會往下疊,變到下一行去 >錯誤範例(多一層,因 row裡面第一層只能是col) ```htmlmixed= <div class="container"> <div class="row"> <div> <div class="col-6 green">標題</div> <div class="col-6 green">標題</div> </div> </div> </div> ``` ![](https://i.imgur.com/Izb6jA3.png) 因row是`display:flex`,裡面第一層的div就會變成一個 而`<div class="col-6 green">標題</div>`即變成一般的div,沒有flex效果,會從上到下排列下來。 > 常見錯誤,在 .col 增加寬度 ![](https://i.imgur.com/Oj4yLhj.png) 因col已給width的限制,如上圖col-6即定義width:50%,不需要再給一次寬度限制 > 常見錯誤,在格線系統調整左右 margin 與 padding > ![](https://i.imgur.com/zmPKeXG.png) 因兩個col-6加起來就是100%,再加`margin-right: 30px;`就超過了,故會往下排 ![](https://i.imgur.com/E5ytglT.png) bs5已有padding的設定 > 常見觀念:可以加上下 的 margin 與 padding bs5使用`box-sizeing:border-box`將border往內推,故不會影響的整體高度(每日任務) > 常見觀念:最外層至少補一個 container row外層沒有container,就會是滿版,依照瀏覽器去延伸 container是個容器,即內容會呈現水平居中 正確範例(row的外層不一定是container) ```htmlmixed= <div class="container"> <div class="header"> <div class="row"> <div class="col-12"> <div class="h1">標題</div> </div> </div> </div> <div class="row footer"> <div class="col-8">標題</div> <div class="col-4">標題二</div> </div> </div> ``` 只寫col,會自適應寬度,依比例分配併排在一起(因其使用flex的縮寫語法1:1) ```htmlmixed= <div class="container"> <div class="row"> <div class="col green">標題</div> <div class="col green">標題</div> </div> </div> ``` ![](https://i.imgur.com/7JoaLRn.png) 從上至下排版(col-12) ```htmlmixed= <div class="container"> <div class="row"> <div class="col-12 green">標題</div> <div class="col-12 green">標題</div> </div> </div> ``` ![](https://i.imgur.com/WO0lN64.png) 正確範例(container裡面第一層容器不一定要是row,因可能為滿版設計,不一定要符合格線系統) ```htmlmixed= <div class="container"> <div class="row header"> <div class="col-3"></div> <div class="col-9"></div> </div> <div class="content"> <div class="row"> <div class="col-3">選單</div> <div class="col-9"></div> </div> </div> <div class="footer"> <div class="p">表尾</div> </div> </div> ``` 正確範例(設計header和footer為滿版) ```htmlmixed= <div class="header"> <h1 class="logo"><a href="">公司名稱</a></h1> <ul> <li><a href="">連結1</a></li> <li><a href="">連結2</a></li> <li><a href="">連結3</a></li> </ul> </div> <div class="container content"> <div class="row"> <div class="col-3">123</div> <div class="col-9"></div> </div> </div> <div class="footer"> <p>表尾</p> </div> ``` > 常見觀念:整體格線邏輯是一致 預留空間給版型,以保有比較多的彈性 ex.若字數增加,不會跑版 ## BS5 格線斷點設計 * [文件位置](https://bootstrap5.hexschool.com/docs/5.0/layout/grid/#grid-options) * 手機sm,平版md.lg * boostrap 5 預設為手機優先(col-4、col-8即在設定手機以上的版型),col-md-4、col-md-8才是設定平版以上版型 * [範例處](https://codepen.io/hexschool/pen/OJpXqVj?editors=1100) ![](https://i.imgur.com/DQVevsr.png) > 若想做網站會先做 PC 版,可用 md(ipad size)、lg(tab和pc之間) 當起手式 先看權重,再看順序(後面覆蓋前面) 可同時寫四至五個class的設定,去斷點 通常寫三個設定即可,因若此三個設定的條件不滿足,就會變成手機版,通常寫md.lg,很少寫sm和xl ## 格線系統與元件整合 * 容器可以放很多元件,例如鉛筆盒就是容器,橡皮擦、筆就是元件 * 容器和元件的樣式分開設計,元件效果亦可分顏色、大小等樣式分開設定 ```htmlmixed= .btn{ width: 50px; display: inline-block; height: 400px; padding: 2px; } .btn-primary{ background: blue; } .btn-lg{ padding: 20px; } ``` * [範例處](https://codepen.io/liao/pen/abvaXyy?editors=1100) ## 網站範例 + 通用類別搭配 ![](https://i.imgur.com/PcCYHGr.png) 通用類別補足容器或元件的細節,亦有設定斷點的功能 d-md-none:即display:none,平版(768)以上[隱藏](https://bootstrap5.hexschool.com/docs/5.0/utilities/display/#hiding-elements) mb-md-5:平版以上,有[間距](https://bootstrap5.hexschool.com/docs/5.0/utilities/spacing/)margin-bottom [Flex](https://bootstrap5.hexschool.com/docs/5.0/utilities/flex/)最常用,因很多情況下不會用到格線系統,可改變軸向,例如:可設定在手機時元件在左側,平版以上元件在右側 * [IT 邦幫忙](https://ithelp.ithome.com.tw/) - 手機版時隱藏右側內容 (d-none、d-lg-block) * [六角學院](https://www.hexschool.com/) - 判斷哪些地方有用到 .row 哪些地方沒有 通常選單不做col,因字數不定,亦可能新增其他選單,用navbar,支援漢堡選單 滿版設計用或不用格線系統皆可,若不用格線系統,則可用text-align:center去讓文字置中 ![](https://i.imgur.com/Nj4XyzQ.png) 因row本身是display:flex,會併排,此用到[justify-content](https://bootstrap5.hexschool.com/docs/5.0/utilities/flex/#justify-content)-center,以通用類別去改變 flex 物件在主軸上的對齊置中。亦有.justify-content-md-center等,可針對不同斷點去設計。 * [甜點電商表尾](https://wcc723.github.io/F2E-PK/products.html) - 表尾設計 + row 裡面再加 .col flex-column:靠上靠下,去拉出高度 ![](https://i.imgur.com/qe65jDL.png) * [Bootstrap Template](https://bootstrapmade.com/bootstrap-4-templates/) - 設計稿網站,一次搞懂所有格線系統用法 ![](https://i.imgur.com/TAWuMh0.png) Your email address部分 可用.row.justify-content-center>.col-6 photoshop 無格線系統設計 Adobe XD,Sketch figma illustrator 有[格線系統](https://wcc723.github.io/design/2018/10/19/grid-system-2/)設計 格線裡面可以還有格線 col是100%解析度,可以在它裡面再加row ```htmlmixed= <div class="container"> <div class="row "> <div class="col-3">左邊選單</div> <div class="col-9"> <div class="row"> <div class="col-6 green">Cras justo odio</div> <div class="col-6 green">Cras justo odio</div> <div class="col-6 green">Cras justo odio</div> </div> </div> </div> </div> ``` ![](https://i.imgur.com/f2doyrc.png)

    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
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    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