龔琪雅
    • 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
      • Invitee
    • 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
    • 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 Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync 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
Invitee
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
--- title: Flex Panel Gallery --- > 【目次】 > [TOC] > Reference Website: > 1. [重新認識 JavaScript: Day 15 隱藏在 "事件" 之中的秘密](https://ithelp.ithome.com.tw/articles/10192015) > 2. [[筆記] JS30系列:監聽按鍵事件及撥放音效(Day1)](https://pjchender.blogspot.com/2017/01/js30day1.html) > 3. [Wibibi 網頁設計教學百科](https://www.wibibi.com/) > 4. [圖解:CSS Flex 屬性一點也不難](https://wcc723.github.io/css/2017/07/21/css-flex/) > 5. [「JS30紀錄&心得」05 - Flex Panel Gallery](https://guahsu.io/2017/05/JavaScript30-05-Flex-Panel-Gallery/) > 6. [HTML DOM - 選單開合範例](https://www.youtube.com/watch?v=SWhNYC6QYDc) ## **Flex Panel Gallery** ### **HTML** ```htmlmixed= <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Flex Panel Gallery</title> </head> <body> <div class="panels"> <div class="panel panel1"> <p>Hey</p> <p>Let's</p> <p>Dance</p> </div> <div class="panel panel2"> <p>Give</p> <p>Take</p> <p>Receive</p> </div> <div class="panel panel3"> <p>Experience</p> <p>It</p> <p>Today</p> </div> <div class="panel panel4"> <p>Give</p> <p>All</p> <p>You can</p> </div> <div class="panel panel5"> <p>Life</p> <p>In</p> <p>Motion</p> </div> </div> </body> </html> ``` --- ### **CSS** ```htmlmixed= <link href='https://fonts.googleapis.com/css?family=Amatic+SC' rel='stylesheet' type='text/css'> <style> html { box-sizing: border-box; /*box-sizing用來調整區塊的內距與邊框 border-box包含內容寬度、內距與邊框寬度。 content-box設定的寬度僅為內容寬度,而內距與邊框額外加上去。 inherit繼承至父層的 broder-sizing 設定値。 */ background: #ffc600; font-family: 'helvetica neue'; font-size: 20px; /*字的大小*/ font-weight: 200; } body { margin: 0; /*定義一個區域(例如DIV 或span)的外邊界距離,俗稱外距*/ } *, *:before, *:after { box-sizing: inherit; } .panels { min-height: 100vh; /*最低高度值*/ overflow: hidden; /*元素超過某個範圍的時候該如何呈現 hidden自動隱藏超出的文字或圖片*/ display: flex; /*宣告*/ } .panel { background: #6B0F9C; box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.1); /* inset offset-x offset-y blur-radius spread-radius 陰影顏色; inset:用來設定內陰影*/ color: white; text-align: center; align-items: center; /* Safari transitionend event.propertyName === flex */ /* Chrome + FF transitionend event.propertyName === flex-grow */ transition: font-size 0.7s cubic-bezier(0.61, -0.19, 0.7, -0.11), flex 0.7s cubic-bezier(0.61, -0.19, 0.7, -0.11), background 0.2s; /* transition: property duration timing-function delay; property用來定義可以產生 transition 屬性效果的屬性名稱,例如寬度、背景顏色 ...。 duration用來定義 transition 屬性發生的時間,單位為秒。 timing-function用來定義 transition 效果的發生速度。 delay用來定義多久之後開始發生 transition 效果。*/ font-size: 20px; /*字的大小*/ background-size: cover; background-position: center; flex: 1; justify-content: center; /* 確定項目位於容器中心(可用於留白的語法)*/ display: flex; flex-direction: column; /*改變軸線方向 column垂直從上往下排列*/ } .panel1 { background-image: url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); } .panel2 { background-image: url(https://source.unsplash.com/1CD3fd8kHnE/1500x1500); } .panel3 { background-image: url(https://images.unsplash.com/photo-1465188162913-8fb5709d6d57?ixlib=rb-0.3.5&q=80&fm=jpg&crop=faces&cs=tinysrgb&w=1500&h=1500&fit=crop&s=967e8a713a4e395260793fc8c802901d); } .panel4 { background-image: url(https://source.unsplash.com/ITjiVXcwVng/1500x1500); } .panel5 { background-image: url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); } /* Flex Items */ .panel>* { margin: 0; width: 100%; transition: transform 0.5s; /*transition屬性實現簡單旋轉效果*/ flex: 1 0 auto; /*flex-grow flex-shrink flex-basis flex-grow: 元件的伸展性 flex-shrink: 元件的收縮性 flex-basis: 元件的基準值*/ display: flex; justify-content: center; /* 確定項目位於容器中心(可用於留白的語法)*/ align-items: center; /*交錯軸的對齊設定*/ } /* :first-child() & :last-child() CSS的:偽類別,分別可以選取first(第一個)/last(最後一個)子元素*/ .panel>*:first-child { transform: translateY(-100%); /*translateY(y) 定義 Y 軸方向的 2D 轉換*/ } .panel.open-active>*:first-child { transform: translateY(0); } .panel>*:last-child { transform: translateY(100%); } .panel.open-active>*:last-child { transform: translateY(0); } .panel p { text-transform: uppercase; /*控制文章中的文字字母大小寫*/ font-family: 'Amatic SC', cursive; text-shadow: 0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45); /*X 軸方向的陰影 Y 軸方向的陰影 模糊範圍 陰影顏色*/ font-size: 2em; } .panel p:nth-child(2) { font-size: 4em; } .panel.open { flex: 5; font-size: 40px; } </style> ``` --- ### **JavaScript** * .querySelector("class") * 一種JS 的CSS 選擇器 * 如果找不到就會回傳null ,不然就回傳第一個符合的元素 * .querySelectorAll("class名稱") * 取出所有符合class的元素 * .classList * 可以管理標籤class的設定 * toggle * 可以切換提供的class名稱 * propertyName * 當發生transitionend事件時,propertyName屬性返回與轉換關聯的CSS屬性的名稱。 * includes * 判斷陣列是否包含特定的元素 * forEach() * 將陣列內的每個元素,皆傳入並執行給定的函式一次。 * .addEventListener() * 監聽事件 * 第一個變數放 'click' 代表監聽滑鼠 * 第二個變數代表待這第一個變數發生的時候,要執行怎樣的事情 * transitionend * 在CSS完成後觸發 ```javascript= <script> let panels = document.querySelectorAll('.panel'); //宣告一個上次點擊的Panel,預設先給他panels let lastClickPanel = document.querySelector('.panels'); function toggleOpen() { //每次檢查進入的element與上次進入的element是不是相同 //若不相同,則把上次點擊的element移除open效果 //再把lastClickPanel指向為這次的elment if (this !== lastClickPanel) { lastClickPanel.classList.remove('open'); lastClickPanel = this; } this.classList.toggle('open'); } // 參數 e 就是上面說的事件物件 (Event Object) // 因為是參數,當然也可以自己定義名稱 function toggleActive(e) { console.log(e.propertyName); if (e.propertyName.includes('flex')) { this.classList.toggle('open-active'); } } panels.forEach(panel => panel.addEventListener('click', toggleOpen)); panels.forEach(panel => panel.addEventListener('transitionend', toggleActive)); </script> ```

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