助教天團
      • 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
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners 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
    • 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 Help
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
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners 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: 30 天軟體工程師體驗營|2025 --- # 🏅 切版任務 Day24 - Swiper 輪播套件 ### Swiper.js 這是一個 JS 的輪播套件,載入套件,撰寫基本 HTML 結構、JS 設定,即可製作出簡易的輪播效果,大家可以嘗試運用看看。 從 [Get Started 頁面](https://swiperjs.com/get-started/) 就可以看到要使用此套件有哪些引入方法, 這邊我們就先嘗試使用 [CDN](https://swiperjs.com/get-started#use-swiper-from-cdn) 載入。 ![](https://imgur.com/GUmSL7u.png) ```htmlembedded= <!-- 貼到 <head> 內 --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css" /> <!-- 貼到 </body> 之前 --> <script src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script> ``` > 使用 CodePen 可以直接將 `href`、`src` 內連結分別貼至 Settings CSS、JS 區塊「Add External Stylesheets/Pens」內(詳細可以再觀看下方範例) 接下來了解基本使用方式,這邊會以設計稿的「部落格精選區塊」來作範例 ### HTML 結構: 1. `.swiper` 是 Swiper 的主要容器,必須存在 2. `.swiper-wrapper` 是所有 slide 的包裹區塊,是 Swiper 的固定結構 3. `.swiper-slide`:每一個幻燈片項目 4. `.swiper-button-prev` / `.swiper-button-next`: 是左右導航箭頭的容器。 整體的結構會如以下: ``` <div class="container"> <div class="swiper"> <ul class="swiper-wrapper"> <li class="swiper-slide">...卡片內容...</li> <!-- 多個 slide --> </ul> <!-- 左箭頭 --> <div class="swiper-button-prev"></div> <!-- 右箭頭 --> <div class="swiper-button-next"></div> </div> </div> ``` <iframe height="300" style="width: 100%;" scrolling="no" title="每日任務 - 🏅 Swiper RWD 變換排版調整解答" src="https://codepen.io/yen-kg/embed/MYYzQXQ?default-tab=html%2Cresult" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true"> See the Pen <a href="https://codepen.io/yen-kg/pen/MYYzQXQ"> 每日任務 - 🏅 Swiper RWD 變換排版調整解答</a> by Yen Kg (<a href="https://codepen.io/yen-kg">@yen-kg</a>) on <a href="https://codepen.io">CodePen</a>. </iframe> ### ### CSS 說明與客製箭頭: 1. Swiper 會自動加上一個 ::after 製作箭頭,如果之後要使用自訂的箭頭,要先關掉預設箭頭: ``` .swiper-button-prev::after, .swiper-button-next::after { display: none; } ``` 2. 調整自訂箭頭的外觀與位置 * position: absolute; 搭配 top: 50% 讓箭頭垂直置中。 * left: -20px / right: -20px 控制箭頭與 Swiper 的距離。 * border-radius: 50% 搭配 background-color 做出圓形箭頭按鈕。 * box-shadow 增加立體感。 * display: flex + align-items + justify-content 可讓 icon 水平垂直居中。 ``` .swiper-button-prev, .swiper-button-next { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; background-color: white; border-radius: 50%; box-shadow: 0 0 6px rgba(0, 0, 0, 0.2); display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 10; } .swiper-button-prev { left: -20px; } .swiper-button-next { right: -20px; } .swiper-button-prev i, .swiper-button-next i { color: #333; font-size: 18px; } ``` 最後呈現的效果會如以下: <iframe height="300" style="width: 100%;" scrolling="no" title="每日任務 - 🏅 Swiper 輪播套件 - 範例 1" src="https://codepen.io/yen-kg/embed/pvvQLex?default-tab=html%2Cresult" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true"> See the Pen <a href="https://codepen.io/yen-kg/pen/pvvQLex"> 每日任務 - 🏅 Swiper 輪播套件 - 範例 1</a> by Yen Kg (<a href="https://codepen.io/yen-kg">@yen-kg</a>) on <a href="https://codepen.io">CodePen</a>. </iframe> 接著我們要將箭頭移動到外層 1. 在 .swiper 的外層加上一層 div (.swiper-wrapper-area) 2. 在 .swiper-wrapper-area 加上以下 CSS ``` .swiper-wrapper-area { position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; } ``` 3. 最後再將 .swiper-button-prev / next 移動到 .swiper 的外層 整體的結構會如以下: <iframe height="300" style="width: 100%;" scrolling="no" title="每日任務 - 🏅 Swiper 輪播套件 - 範例 2" src="https://codepen.io/yen-kg/embed/YPPRLqY?default-tab=html%2Cresult" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true"> See the Pen <a href="https://codepen.io/yen-kg/pen/YPPRLqY"> 每日任務 - 🏅 Swiper 輪播套件 - 範例 2</a> by Yen Kg (<a href="https://codepen.io/yen-kg">@yen-kg</a>) on <a href="https://codepen.io">CodePen</a>. </iframe> ## 題目 複製此 [CodePen 範例](https://codepen.io/yen-kg/pen/PwwxeXv),請在 HTML 中加入左右箭頭的標籤,完成跟範例中一樣的箭頭樣式。 並且請將箭頭移動到輪播區塊之外 (如下圖) ![image](https://hackmd.io/_uploads/rkmcUzkbeg.png) ## 回報流程 將答案貼在 CodePen 並複製 CodePen 連結貼至「回報區」回報 (也可以將答案直接貼至「回報區」) ![](https://i.imgur.com/vftL5i0.png) <!-- 解答: https://codepen.io/yen-kg/pen/emmQKzG --> 回報區 --- | 報數 | Discord 名字 | Codepen/其他回饋 | |:----:|:-------------------:|:---------------------------------------------------------------------------------------------------------------------------------:| | 1 | 4chan | [codepen](https://codepen.io/ijuolaqc-the-looper/pen/xbGGJpe) | | 2 | 7Lun | [Day24-codepen](https://codepen.io/mfyvqhsn-the-bold/pen/LEVVBaE) | | 3 | dean | [codepen](https://codepen.io/ch933114/pen/gbppjym?editors=1100) | | 4 | 謝天 | [codepen](https://codepen.io/crisxie/pen/MYwwqWZ) | | 5 | NAOJUN | [codepen](https://codepen.io/NAOJUN/pen/jEPPvRj) | | 6 | Melanie | [codepen](https://codepen.io/pnrcspte-the-animator/pen/azOORZw) | | 7 | Joseph_Kyuu | [codepen](https://codepen.io/zrzfastd-the-reactor/pen/OPVVBze) | | 8 | RUDY | [CodePen](https://codepen.io/Rudy-crw/pen/xbGGyRX?editors=1100) | | 9 | 登登登 | [CodePen](https://codepen.io/Duncanin/pen/emNNPwe) | | 10 | nora_zizi | [CodePen](https://codepen.io/Nora-Ch/pen/XJbbyWE) | | 11 | Min | [CodePen](https://codepen.io/cvqevoxk-the-decoder/pen/emNNbda) | | 12 | Aoi | [CodePen](https://codepen.io/zching07/pen/gbppdLX) | | 13 | WEIWEI | [CodePen](https://codepen.io/weiwei93/pen/pvJJZrp) | | 14 | jimmy.0706 | [CodePen](https://codepen.io/JimmyMao/pen/WbvvqXO) | |15|蛋殼|[Codepen](https://codepen.io/weybrian/pen/raVVXWE) | 16 | tina01170 | [CodePen](https://codepen.io/tina-huang-the-bashful/pen/wBaKvaM?editors=1100) | | 17 | Cyan66 | [CodePen](https://codepen.io/Cyan66/pen/PwqPqNx) | | 18 | stone | [Codepen](https://codepen.io/bgrwlzoz-the-reactor/pen/EajjMEr)| | 19 | Holly | [CodePen](https://codepen.io/LEE-HOLLY/pen/ogXjjyK) | | 20 | zhe | [CodePen](https://codepen.io/dotheright/pen/XJbmpqP) | | 21 | pastor | [CodePen](https://codepen.io/peter_hung/pen/raVOeLL) | | 22 | andy | [CodePen](https://codepen.io/ewnblckz-the-styleful/pen/bNdVrEa) | | 23 | Hugh | [CodePen](https://codepen.io/Hugh-Chen/pen/bNdVJqa) | | 24 | cks40660 | [CodePen](https://codepen.io/CKS40660/pen/wBaaLwM) | | 25 | Jessie_Yu | [Jessie_Yu 的 Codepen](https://codepen.io/bakyfkso-the-looper/pen/MYwKmPy)| | 26 | Tetsu | [CodePen](https://codepen.io/ttgchang/pen/ByNjbwy) | | 27 | oyll | [CodePen](https://codepen.io/dizzydog-rgb/pen/bNdEjBN?editors=1100) | | 28 | 力文 | [CodePen](https://codepen.io/liwenchiou/pen/yyNOORL?editors=1100) | | 29 | An | [CodePen](https://codepen.io/bzrpsbjq-the-encoder/pen/zxGqRjr) | | 30 | Aidd. | [Codepen](https://codepen.io/aiddchen/pen/MYweWNo) | 31 | jingle0900 | [Codepen](https://codepen.io/EvaLi0472/pen/bNdpaNw) | 32 | Leonard | [Codepen](https://codepen.io/hyyfjqra-the-sans/pen/gbpwGrw) | 33 | William Hsieh | [CodePen](https://codepen.io/lsaimqxa-the-vuer/pen/zxGZxwK) | | 34 | Zhu | [CodePen](https://codepen.io/codepenplayer/pen/gbpxGPe) | | 35 | Astrid | [6/7](https://codepen.io/astrid321654/pen/RNPZdEb) | | 36 | 禹成林| [CodePen](https://codepen.io/useirin/pen/myJmBmv) | | 37 | mercury2508. | [CodePen](https://codepen.io/Mercury2508/pen/JodraJV) | | 38 | Klaus Chen | [CodePen](https://codepen.io/Klaus-Chen/pen/azOYbGN?editors=1100) | | 39 | ann.328 |[Codepen](https://codepen.io/yqmegupa-the-styleful/pen/azOYJjV)| | 40 | Chuang | [CodePen](https://codepen.io/uidoytjq-the-solid/pen/ByNPvxr) | | 41 | Rogan | [CodePen](https://codepen.io/RoganHsu/pen/dPogPMb) | | 42 | JiaMori | [CodePen](https://codepen.io/jiamori/pen/qEdJpdg) | <!-- 【快速複製】 | 00 | user | [CodePen]() | -->

    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