SlideShare a Scribd company logo
1 of 54
Download to read offline
consectetur adipisicing elit, sed do
eiusmod tempor incididunt
consectetur adipisicing elit,
sed do eiusmod tempor
incididunt dolor in
reprehenderit in voluptate
eiusmod
sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt
mollit anim id est laborum.
yourcompany
• 六⾓角學院講師

⾼高雄前端社群核⼼心成員
• 專長:
• CSS、Sass
• 視覺設計
• Personal Blog: http://wcc723.github.io/
• Facebook: https://fb.com/wccCasper
• 快速了解 Grid Layout
• 案例說明
• 他是⼀個新的 CSS 屬性,直到今年才有比較多的
瀏覽器⽀援。

Chrome 57, Firefox 52, Safari 10.1…
• CSS Grid Layout 可以處理⼆維排版 (欄與列)

Flex 僅能處理 欄或列
• CSS Grid 與 Flex 可以共⽤
yourcompany
• display
• grid-template
• grid-template-columns
• grid-template-rows
• grid-template-areas
• grid-gap
• grid-column-gap
• grid-row-gap
• justify-items (內部元件)
• align-items (內部元件)
• justify-content (整體元件)
• align-content (整體元件)
• grid-auto-columns
• grid-auto-rows
• grid-auto-flow
必要
排版屬性
欄欄列列間隔
對⿑齊屬性
簡易易⾃自動屬性
• grid-column
• grid-column-start
• grid-column-end
• grid-row
• grid-row-start
• grid-row-end
• grid-area
• justify-self
• align-self
欄欄位起迄
列列位起迄
Area 定義
對⿑齊屬性
.container {
}
50px 200px auto
100px
auto
… …
gap
display: grid;
grid-template-columns: 50px 200px auto 200px 50px;
grid-gap: 10px 15px;
grid-template-rows: 100px auto 100px ;
.container {
display: grid;
grid-template-columns: 50px 200px auto 200px 50px;
grid-template-rows: 100px auto 100px ;
grid-gap: 10px 15px;
}
50px 200px auto
1 2 3 4 5 6
1
2
3
4
100px
auto
… …
.item-xxx{
grid-column: start / end;
grid-row: start / end;
}
50px 200px auto
1 2 3 4 5 6
1
2
3
4
100px
auto
… …
grid-column: 1 / 3;
grid-row: 2 / 3;
grid-column: 1 / 3;
grid-row: 2 / 3;
.item-xxx{
grid-column: start / end;
grid-row: start / end;
}
50px 200px auto
1 2 3 4 5 6
1
2
3
4
100px
auto
… …
grid-column: 1 / 6;
grid-row: 1 / 2;
grid-column: 1 / 3;
grid-row: 2 / 3;
grid-column: 3 / 6;
grid-row: 3 / 4;
Navbar
Header
Content
Menu
Content
Header
Navbar
Menu
Navbar
Header
Content
Menu
300px auto
Content
Header
Navbar
Menu
1
2
3
4
1 2 3
5
範例 網⾴

https://codepen.io/Wcc723/full/EvWZgo/
auto50px 200px … …
auto50px 200px … …
justify-content (整體元件⽔平對齊)
auto50px 200px … …
justify-content: flex-end
auto50px 200px … …
justify-content: flex-start
auto50px 200px … …
justify-content: center
justify-content: space-between
auto50px 200px … …
auto
50px 200px … …
align-content: (整體元件垂直對齊)
align-content: flex-start;
auto
50px 200px … …
auto
50px 200px … …
• justify-items: center (內部元件⽔平位置)
• align-items: center (內部元件垂直位置)
auto
50px 200px … …
• justify-items: center (內部元件⽔平位置)
• align-items: center (內部元件垂直位置)
• justify-self: flex-end;
• align-self: flex-start;
外層 justify-content
外層 align-content
外層 justify-items
外層 align-items
內層 justify-self
內層 align-self
• 對齊排版
• http://wcc723.github.io/WorkShop-gh-pages/
cssGridDisplay/
略懂了
.container {
display: grid;
grid-template-columns: 

repeat(16, 45px);
grid-template-rows: 

repeat(16, 45px);
}
grid-column: 3 / 11;
grid-row: 3 / 11;
.container {
display: grid;
grid-template-columns: 

repeat(16, 45px);
grid-template-rows: 

repeat(16, 45px);
}
蒙德⾥安範例

https://goo.gl/erWkg6
貪食蛇例

http://wcc723.github.io/WorkShop-gh-pages/snakesnake/
.grid {
transform: skewY(-12deg);
}
參考說明

https://goo.gl/A7ufbs
Stripe 網⾴

https://stripe.com/connect
Grid Layout 平⾯風格網⾴

https://goo.gl/vkbNrZ
優點
• 可以做出類似平⾯設計風格的網⾴
• 排版模式又多了⼀種選擇
缺點
• ⽬前⽀援度還不⾜
• 很多坑⽤過才會體會
範例
• https://codepen.io/Kseso/pen/xqNdmO
• https://stripe.com/connect
• https://goo.gl/vkbNrZ
參考⽂件
• https://css-tricks.com/snippets/css/complete-guide-grid/
• https://developer.mozilla.org/en-US/docs/Web/CSS/
CSS_Grid_Layout
Q and A

More Related Content

What's hot

BEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodologyBEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodologyVarya Stepanova
 
BEM it! Introduction to BEM
BEM it! Introduction to BEMBEM it! Introduction to BEM
BEM it! Introduction to BEMVarya Stepanova
 
Bootstrap Web Development Framework
Bootstrap Web Development FrameworkBootstrap Web Development Framework
Bootstrap Web Development FrameworkCindy Royal
 
Web application framework
Web application frameworkWeb application framework
Web application frameworkPankaj Chand
 
Cobol Web com Net Express 3.1/4.0/5.x - Parte 1
Cobol Web com Net Express 3.1/4.0/5.x - Parte 1Cobol Web com Net Express 3.1/4.0/5.x - Parte 1
Cobol Web com Net Express 3.1/4.0/5.x - Parte 1Altair Borges
 
Understanding the Web Page Layout
Understanding the Web Page LayoutUnderstanding the Web Page Layout
Understanding the Web Page LayoutJhaun Paul Enriquez
 
Vb script power_shellでメール送信
Vb script power_shellでメール送信Vb script power_shellでメール送信
Vb script power_shellでメール送信Naoyuki Sano
 
SpringDataJPA - 스프링 캠프
SpringDataJPA - 스프링 캠프SpringDataJPA - 스프링 캠프
SpringDataJPA - 스프링 캠프Younghan Kim
 
IBConsole 日本語版+α ユーザーズガイド
IBConsole 日本語版+α ユーザーズガイドIBConsole 日本語版+α ユーザーズガイド
IBConsole 日本語版+α ユーザーズガイドHideaki Tominaga
 
An Introduction to Vuejs
An Introduction to VuejsAn Introduction to Vuejs
An Introduction to VuejsPaddy Lock
 
CSS For Backend Developers
CSS For Backend DevelopersCSS For Backend Developers
CSS For Backend Developers10Clouds
 
Le référencement d’un site e-Commerce
Le référencement d’un site e-CommerceLe référencement d’un site e-Commerce
Le référencement d’un site e-CommerceCYB@RDECHE
 
20160420 ROS 3차 강의 (for 아스라다 팀)
20160420 ROS 3차 강의 (for 아스라다 팀)20160420 ROS 3차 강의 (for 아스라다 팀)
20160420 ROS 3차 강의 (for 아스라다 팀)Yoonseok Pyo
 
Introduction to Bootstrap: Design for Developers
Introduction to Bootstrap: Design for DevelopersIntroduction to Bootstrap: Design for Developers
Introduction to Bootstrap: Design for DevelopersMelvin John
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript TutorialBui Kiet
 

What's hot (20)

BEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodologyBEM it! Introduction to BEM methodology
BEM it! Introduction to BEM methodology
 
CSS 語法教學
CSS 語法教學CSS 語法教學
CSS 語法教學
 
BEM it! Introduction to BEM
BEM it! Introduction to BEMBEM it! Introduction to BEM
BEM it! Introduction to BEM
 
Bootstrap Web Development Framework
Bootstrap Web Development FrameworkBootstrap Web Development Framework
Bootstrap Web Development Framework
 
Bootstrap.pptx
Bootstrap.pptxBootstrap.pptx
Bootstrap.pptx
 
Web application framework
Web application frameworkWeb application framework
Web application framework
 
Cobol Web com Net Express 3.1/4.0/5.x - Parte 1
Cobol Web com Net Express 3.1/4.0/5.x - Parte 1Cobol Web com Net Express 3.1/4.0/5.x - Parte 1
Cobol Web com Net Express 3.1/4.0/5.x - Parte 1
 
Introduction to Bootstrap
Introduction to BootstrapIntroduction to Bootstrap
Introduction to Bootstrap
 
Understanding the Web Page Layout
Understanding the Web Page LayoutUnderstanding the Web Page Layout
Understanding the Web Page Layout
 
HTML e CSS
HTML e CSSHTML e CSS
HTML e CSS
 
Vb script power_shellでメール送信
Vb script power_shellでメール送信Vb script power_shellでメール送信
Vb script power_shellでメール送信
 
SpringDataJPA - 스프링 캠프
SpringDataJPA - 스프링 캠프SpringDataJPA - 스프링 캠프
SpringDataJPA - 스프링 캠프
 
IBConsole 日本語版+α ユーザーズガイド
IBConsole 日本語版+α ユーザーズガイドIBConsole 日本語版+α ユーザーズガイド
IBConsole 日本語版+α ユーザーズガイド
 
An Introduction to Vuejs
An Introduction to VuejsAn Introduction to Vuejs
An Introduction to Vuejs
 
CSS For Backend Developers
CSS For Backend DevelopersCSS For Backend Developers
CSS For Backend Developers
 
Le référencement d’un site e-Commerce
Le référencement d’un site e-CommerceLe référencement d’un site e-Commerce
Le référencement d’un site e-Commerce
 
20160420 ROS 3차 강의 (for 아스라다 팀)
20160420 ROS 3차 강의 (for 아스라다 팀)20160420 ROS 3차 강의 (for 아스라다 팀)
20160420 ROS 3차 강의 (for 아스라다 팀)
 
Introduction to Bootstrap: Design for Developers
Introduction to Bootstrap: Design for DevelopersIntroduction to Bootstrap: Design for Developers
Introduction to Bootstrap: Design for Developers
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
 
Bootstrap 5 ppt
Bootstrap 5 pptBootstrap 5 ppt
Bootstrap 5 ppt
 

More from Chih-cheng Wang

六角學院 - 從社群到公司
六角學院 - 從社群到公司六角學院 - 從社群到公司
六角學院 - 從社群到公司Chih-cheng Wang
 
網址管理與 DNS 託管全攻略
網址管理與 DNS 託管全攻略網址管理與 DNS 託管全攻略
網址管理與 DNS 託管全攻略Chih-cheng Wang
 
高雄前端社群 Web 開發讀書會 - 網頁設計規劃
高雄前端社群 Web 開發讀書會 - 網頁設計規劃高雄前端社群 Web 開發讀書會 - 網頁設計規劃
高雄前端社群 Web 開發讀書會 - 網頁設計規劃Chih-cheng Wang
 
Bootstrap4 與他的好搭檔
Bootstrap4 與他的好搭檔Bootstrap4 與他的好搭檔
Bootstrap4 與他的好搭檔Chih-cheng Wang
 
Sass 基礎教學 - 高雄前端社群(CSS 讀書會)
Sass 基礎教學 - 高雄前端社群(CSS 讀書會)Sass 基礎教學 - 高雄前端社群(CSS 讀書會)
Sass 基礎教學 - 高雄前端社群(CSS 讀書會)Chih-cheng Wang
 
專業前端 都如何管理 CSS
專業前端 都如何管理 CSS專業前端 都如何管理 CSS
專業前端 都如何管理 CSSChih-cheng Wang
 
響應式網頁實作坊
響應式網頁實作坊響應式網頁實作坊
響應式網頁實作坊Chih-cheng Wang
 
建立 Sass 環境,透過 Node sass
建立 Sass 環境,透過 Node sass建立 Sass 環境,透過 Node sass
建立 Sass 環境,透過 Node sassChih-cheng Wang
 
CSS 讀書會 - 1 (Grid system)
CSS 讀書會 - 1 (Grid system)CSS 讀書會 - 1 (Grid system)
CSS 讀書會 - 1 (Grid system)Chih-cheng Wang
 
Slack 基本功能介紹
Slack 基本功能介紹Slack 基本功能介紹
Slack 基本功能介紹Chih-cheng Wang
 

More from Chih-cheng Wang (11)

六角學院 - 從社群到公司
六角學院 - 從社群到公司六角學院 - 從社群到公司
六角學院 - 從社群到公司
 
網址管理與 DNS 託管全攻略
網址管理與 DNS 託管全攻略網址管理與 DNS 託管全攻略
網址管理與 DNS 託管全攻略
 
高雄前端社群 Web 開發讀書會 - 網頁設計規劃
高雄前端社群 Web 開發讀書會 - 網頁設計規劃高雄前端社群 Web 開發讀書會 - 網頁設計規劃
高雄前端社群 Web 開發讀書會 - 網頁設計規劃
 
Bootstrap4 與他的好搭檔
Bootstrap4 與他的好搭檔Bootstrap4 與他的好搭檔
Bootstrap4 與他的好搭檔
 
Sass 基礎教學 - 高雄前端社群(CSS 讀書會)
Sass 基礎教學 - 高雄前端社群(CSS 讀書會)Sass 基礎教學 - 高雄前端社群(CSS 讀書會)
Sass 基礎教學 - 高雄前端社群(CSS 讀書會)
 
專業前端 都如何管理 CSS
專業前端 都如何管理 CSS專業前端 都如何管理 CSS
專業前端 都如何管理 CSS
 
響應式網頁實作坊
響應式網頁實作坊響應式網頁實作坊
響應式網頁實作坊
 
建立 Sass 環境,透過 Node sass
建立 Sass 環境,透過 Node sass建立 Sass 環境,透過 Node sass
建立 Sass 環境,透過 Node sass
 
CSS 讀書會 - 1 (Grid system)
CSS 讀書會 - 1 (Grid system)CSS 讀書會 - 1 (Grid system)
CSS 讀書會 - 1 (Grid system)
 
Slack 基本功能介紹
Slack 基本功能介紹Slack 基本功能介紹
Slack 基本功能介紹
 
Google design
Google designGoogle design
Google design
 

[Modern Web] CSS3 Grid Layout