SlideShare a Scribd company logo
CSS Grid
T A B L E L A Y O U T 2 . 0
2
3
Table Layout Grid Frameworks
4
CSS Grid
Grid Terminology
5
6
Grid Container
Grid Item Grid Item Grid Item
Grid Item Grid Item Grid Item
7
Grid Line
Grid Track
Grid Cell
Grid Area
Grid Container Props
8
9
display: grid;
1 0
grid-template-rows / grid-template-columns
Defines the columns and rows of the grid with a space separated list of value. Values represent track size and can be
a px length, percentage, or fraction of free space. Optional names can be given to the generated lines.
grid-template-columns: 40px 50px 1fr 2fr;
grid-column-gap / grid-row-gap
Defines the space between grid tracks.
grid-column-gap: 10px;
grid-row-gap: 15px;
grid-template-rows: [row1-start] 25% [row1-end] 100px [third-line] auto [last-line];
Repeat and minmax functions can also be used for more complex layouts.
grid-template-rows: repeat(4, minmax(20px, 50px) 100px);
1 1
justify-items / align-items
Justify-items aligns a grid items on the row axis, align-items aligns items on the column axis, inside grid cells. Values
can be start, end, center, or stretch (default).
justify-self: start;
justify-self: center;
align-self: end;
align-self: stretch;
justify-content / align-content
Sometimes the total size of your grid might be less than the size of its grid container. This could happen if all of your grid
items are sized with non-flexible units like px. Justify-content will align the grid on the row axis and align-content will align
the grid on the column axis. Values can be start, end, center, stretch, space-around, space-between, space-evenly.
justify-content: start;
justify-content: center;
align-content: space-around;
align-content: space-evenly;
Grid Item Props
1 2
1 3
grid-column-start / grid-column-end / grid-row-start / grid-row-end
Determines a grid item’s location within the grid by referring to specific grid lines. Value can be a number or name
referring to a grid line, “span <number | name>” to span until specified line is hit, or auto.
grid-column-start: 1;
grid-column-end: span col4-start;
grid-row-start: 2
grid-row-end: span 2
justify-self / align-self
Justify-self aligns a grid item on the row axis, align-self aligns on the column axis.
Values can be start, end, center, or stretch (default).
justify-self: start;
justify-self: center;
align-self: end;
align-self: stretch;
Grid Auto Flow
1 4
1 5
grid-auto-flow
If you have grid items that you don't explicitly place on the grid, the auto-placement algorithm kicks in to automatically
place the items. This property controls how the auto-placement algorithm works. It’s similar to flex-direction but with
one special super power.
grid-auto-flow: row;
grid-auto-flow: column;
grid-auto-flow: dense;
Grid Areas
1 6
1 7
grid-template-areas / grid-area
Defines a grid template by referencing the names of the grid areas which are specified with the grid-area property.
Repeating the name of a grid area causes the content to span those cells. A period signifies an empty cell. The syntax
itself provides a visualization of the structure of the grid.
.item-a { grid-area: header; }
.item-b { grid-area: main; }
.item-c { grid-area: sidebar; }
.item-d { grid-area: footer; }
.container {
grid-template-columns: 50px 50px 50px 50px;
grid-template-rows: auto;
grid-template-areas:
"header header header header"
"main main . sidebar"
"footer footer footer footer";
}
1 8
1 9
.header { grid-area: header; }
.main { grid-area: main; }
.sidebar { grid-area: sidebar; }
.footer { grid-area: footer; }
.container {
display: grid;
grid-template-columns: 50px 50px 50px 50px;
grid-template-rows: auto;
grid-template-areas:
"header header header header"
"main main . sidebar"
"footer footer footer footer";
}
2 0
.header { grid-area: header; }
.main { grid-area: main; }
.sidebar { grid-area: sidebar; }
.footer { grid-area: footer; }
.container {
display: grid;
grid-template-columns: 50px 50px 50px 50px;
grid-template-rows: auto;
grid-template-areas:
"header header header header"
"main main . sidebar"
"footer footer footer footer";
}
<div class="container">
<header class="header">Header</header>
<main class="main">Main</main>
<aside class="sidebar">Sidebar</aside>
<footer class="footer">Footer</footer>
</div>
2 1
Table Layout Grid Frameworks CSS Grid
Responsive
2 2
2 3
2 4
.cards {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
grid-gap: 30px;
max-width: 960px;
margin: 0 auto 30px;
}
2 5
.container {
grid-template-columns: 1fr 1fr;
grid-template-rows: auto;
grid-template-areas:
"header header"
"main main”
“sidebar footer”;
@media (——medium-screen) {
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-template-areas:
"header header header header"
"main main . sidebar"
"footer footer footer footer";
}
}
Animation
2 6
2 7
But what about Flex?
2 8
2 9
“The main idea behind the flex layout is to give the container
the ability to alter its items’ width/height (and order) to best
fill the available space (mostly to accommodate to all kind of
display devices and screen sizes).”
— Chris Coyier
3 0
• Flex is one dimensional. Grid is two dimensional.
• A core difference is that Grid’s approach is layout-
first while Flexbox’ approach is content-first.
• If you want to define a layout as a row or a column, that
flexes based on the content inside, then you probably
need flexbox.
• If you want to define a grid and fit content into it in two
dimensions  then  you probably need grid.
But what about Table?
3 1
3 2
Still use tables
…but for tables
3 3
Demo time…
CODEPEN

More Related Content

PPTX
Introducing CSS Grid
Jason Yingling
 
PPTX
Flexbox
Netcetera
 
PDF
Flexbox and Grid Layout
Rachel Andrew
 
PDF
CSS Grid vs. Flexbox
Ecaterina Moraru (Valica)
 
PDF
CSS Day: CSS Grid Layout
Rachel Andrew
 
PDF
CSS3 Media Queries
Russ Weakley
 
PDF
Introduction to CSS3
Doris Chen
 
PPTX
CSS Flexbox (flexible box layout)
Woodridge Software
 
Introducing CSS Grid
Jason Yingling
 
Flexbox
Netcetera
 
Flexbox and Grid Layout
Rachel Andrew
 
CSS Grid vs. Flexbox
Ecaterina Moraru (Valica)
 
CSS Day: CSS Grid Layout
Rachel Andrew
 
CSS3 Media Queries
Russ Weakley
 
Introduction to CSS3
Doris Chen
 
CSS Flexbox (flexible box layout)
Woodridge Software
 

What's hot (20)

PDF
Intro to HTML and CSS basics
Eliran Eliassy
 
PPT
CSS Basics
WordPress Memphis
 
PDF
Introducing CSS Grid Layout
Rachel Andrew
 
PPTX
CSS Animations & Transitions
Edward Meehan
 
PPTX
Css
Hemant Saini
 
PPTX
Css position
Webtech Learning
 
PPT
Cascading Style Sheets (CSS) help
casestudyhelp
 
PPTX
Bootstrap PPT by Mukesh
Mukesh Kumar
 
PPTX
Css selectors
Parth Trivedi
 
PPTX
Flex box
Harish Karthick
 
PPTX
Javascript functions
Alaref Abushaala
 
PPTX
Css Display Property
Webtech Learning
 
PPTX
Css tables
AbhishekMondal42
 
PPTX
html-table
Dhirendra Chauhan
 
PPTX
Css Basics
Jay Patel
 
PPTX
CSS - Text Properties
hstryk
 
PPT
JavaScript & Dom Manipulation
Mohammed Arif
 
PPTX
HTML5 & CSS3
Ian Lintner
 
PPTX
Intro to Flexbox - A Magical CSS Property
Adam Soucie
 
Intro to HTML and CSS basics
Eliran Eliassy
 
CSS Basics
WordPress Memphis
 
Introducing CSS Grid Layout
Rachel Andrew
 
CSS Animations & Transitions
Edward Meehan
 
Css position
Webtech Learning
 
Cascading Style Sheets (CSS) help
casestudyhelp
 
Bootstrap PPT by Mukesh
Mukesh Kumar
 
Css selectors
Parth Trivedi
 
Flex box
Harish Karthick
 
Javascript functions
Alaref Abushaala
 
Css Display Property
Webtech Learning
 
Css tables
AbhishekMondal42
 
html-table
Dhirendra Chauhan
 
Css Basics
Jay Patel
 
CSS - Text Properties
hstryk
 
JavaScript & Dom Manipulation
Mohammed Arif
 
HTML5 & CSS3
Ian Lintner
 
Intro to Flexbox - A Magical CSS Property
Adam Soucie
 
Ad

Similar to CSS Grid (20)

PPT
17523630.ppt
ssusere2bc36
 
PDF
The Grid - The Future of CSS Layout
Ronny Siikaluoma
 
PDF
CSS Grid Layout
Rachel Andrew
 
PDF
Frontend United: Start using CSS Grid Layout today!
Rachel Andrew
 
PPTX
Css Grid Layout - A Short Introduction - Part 1
Adam Michalowski
 
PDF
CSS Grid Layout: An Event Apart Boston 2016
Rachel Andrew
 
PDF
Laying out the future with grid & flexbox - Smashing Conf Freiburg
Rachel Andrew
 
PDF
AEA Chicago CSS Grid Layout
Rachel Andrew
 
PDF
Introduction to CSS Grid Layout
Rachel Andrew
 
PDF
CSS Grid Layout Introduction
Ajara I. Pfannenschmidt
 
PPTX
An introduction to css grid
Cameron Olivier
 
PDF
CSS Grid Layout
All Things Open
 
PDF
CSS Grid Layout - All Things Open
Rachel Andrew
 
PDF
CSS Grid Layout
Rachel Andrew
 
PDF
An Event Apart SF: CSS Grid Layout
Rachel Andrew
 
PDF
Talk Web Design: Get Ready For CSS Grid Layout
Rachel Andrew
 
PDF
CSS Grid Layout for Topconf, Linz
Rachel Andrew
 
PDF
Evergreen websites for Evergreen browsers
Rachel Andrew
 
PDF
CSS Grid Layout - An Event Apart Orlando
Rachel Andrew
 
PDF
CSS Grid Layout for Frontend NE
Rachel Andrew
 
17523630.ppt
ssusere2bc36
 
The Grid - The Future of CSS Layout
Ronny Siikaluoma
 
CSS Grid Layout
Rachel Andrew
 
Frontend United: Start using CSS Grid Layout today!
Rachel Andrew
 
Css Grid Layout - A Short Introduction - Part 1
Adam Michalowski
 
CSS Grid Layout: An Event Apart Boston 2016
Rachel Andrew
 
Laying out the future with grid & flexbox - Smashing Conf Freiburg
Rachel Andrew
 
AEA Chicago CSS Grid Layout
Rachel Andrew
 
Introduction to CSS Grid Layout
Rachel Andrew
 
CSS Grid Layout Introduction
Ajara I. Pfannenschmidt
 
An introduction to css grid
Cameron Olivier
 
CSS Grid Layout
All Things Open
 
CSS Grid Layout - All Things Open
Rachel Andrew
 
CSS Grid Layout
Rachel Andrew
 
An Event Apart SF: CSS Grid Layout
Rachel Andrew
 
Talk Web Design: Get Ready For CSS Grid Layout
Rachel Andrew
 
CSS Grid Layout for Topconf, Linz
Rachel Andrew
 
Evergreen websites for Evergreen browsers
Rachel Andrew
 
CSS Grid Layout - An Event Apart Orlando
Rachel Andrew
 
CSS Grid Layout for Frontend NE
Rachel Andrew
 
Ad

More from Digital Surgeons (20)

PDF
Navigating Your Brand Through Covid-19
Digital Surgeons
 
PDF
SVG Animations
Digital Surgeons
 
PDF
Machine learning
Digital Surgeons
 
PDF
CraftCMS 3.x Deep Dive
Digital Surgeons
 
PDF
Creating great decks: The Origins, the "Why", and 12 Tips to Make Yours Better.
Digital Surgeons
 
PDF
The Science of Story: How Brands Can Use Storytelling To Get More Customers
Digital Surgeons
 
PDF
In Content Strategy, L.E.S.S. is More
Digital Surgeons
 
PDF
Unlock Your Organization Through Digital Transformation
Digital Surgeons
 
PDF
Radical Candor: No BS, helping your team create better work.
Digital Surgeons
 
PDF
Unlocking Creativity: How to Harness the Powers of Design, Art Direction & Cr...
Digital Surgeons
 
PDF
Fight for Yourself: How to Sell Your Ideas and Crush Presentations
Digital Surgeons
 
PDF
Typecurious: A Typography Crash Course
Digital Surgeons
 
PDF
Better Twitch Broadcasting through Rapid Prototyping & Human Centered Design
Digital Surgeons
 
PDF
How to Stream Video Games: A Primer on Twitch.tv
Digital Surgeons
 
PDF
Art, Meet Copy: A Copywriting Primer for Designers
Digital Surgeons
 
PDF
Creating Powerful Customer Experiences
Digital Surgeons
 
PDF
How to Build a Brand Voice Toolkit
Digital Surgeons
 
PDF
Design Thinking: The one thing that will transform the way you think
Digital Surgeons
 
PDF
What You Need to Know About the Future of Wearable Technology
Digital Surgeons
 
PDF
How YouTube is Drastically Changing the Beauty Industry
Digital Surgeons
 
Navigating Your Brand Through Covid-19
Digital Surgeons
 
SVG Animations
Digital Surgeons
 
Machine learning
Digital Surgeons
 
CraftCMS 3.x Deep Dive
Digital Surgeons
 
Creating great decks: The Origins, the "Why", and 12 Tips to Make Yours Better.
Digital Surgeons
 
The Science of Story: How Brands Can Use Storytelling To Get More Customers
Digital Surgeons
 
In Content Strategy, L.E.S.S. is More
Digital Surgeons
 
Unlock Your Organization Through Digital Transformation
Digital Surgeons
 
Radical Candor: No BS, helping your team create better work.
Digital Surgeons
 
Unlocking Creativity: How to Harness the Powers of Design, Art Direction & Cr...
Digital Surgeons
 
Fight for Yourself: How to Sell Your Ideas and Crush Presentations
Digital Surgeons
 
Typecurious: A Typography Crash Course
Digital Surgeons
 
Better Twitch Broadcasting through Rapid Prototyping & Human Centered Design
Digital Surgeons
 
How to Stream Video Games: A Primer on Twitch.tv
Digital Surgeons
 
Art, Meet Copy: A Copywriting Primer for Designers
Digital Surgeons
 
Creating Powerful Customer Experiences
Digital Surgeons
 
How to Build a Brand Voice Toolkit
Digital Surgeons
 
Design Thinking: The one thing that will transform the way you think
Digital Surgeons
 
What You Need to Know About the Future of Wearable Technology
Digital Surgeons
 
How YouTube is Drastically Changing the Beauty Industry
Digital Surgeons
 

Recently uploaded (20)

PPT
Ppt for engineering students application on field effect
lakshmi.ec
 
DOCX
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
PPTX
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
PPTX
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
PDF
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
PDF
Principles of Food Science and Nutritions
Dr. Yogesh Kumar Kosariya
 
PPTX
EE3303-EM-I 25.7.25 electrical machines.pptx
Nagen87
 
PPTX
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PPTX
22PCOAM21 Data Quality Session 3 Data Quality.pptx
Guru Nanak Technical Institutions
 
PDF
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
PDF
Queuing formulas to evaluate throughputs and servers
gptshubham
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PDF
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
PDF
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 
PPTX
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
PDF
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
PDF
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
Hyogeun Oh
 
PPTX
Inventory management chapter in automation and robotics.
atisht0104
 
PDF
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
Ppt for engineering students application on field effect
lakshmi.ec
 
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
Principles of Food Science and Nutritions
Dr. Yogesh Kumar Kosariya
 
EE3303-EM-I 25.7.25 electrical machines.pptx
Nagen87
 
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
22PCOAM21 Data Quality Session 3 Data Quality.pptx
Guru Nanak Technical Institutions
 
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
Queuing formulas to evaluate throughputs and servers
gptshubham
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
Top 10 read articles In Managing Information Technology.pdf
IJMIT JOURNAL
 
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
Hyogeun Oh
 
Inventory management chapter in automation and robotics.
atisht0104
 
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 

CSS Grid

  • 1. CSS Grid T A B L E L A Y O U T 2 . 0
  • 2. 2
  • 3. 3 Table Layout Grid Frameworks
  • 6. 6 Grid Container Grid Item Grid Item Grid Item Grid Item Grid Item Grid Item
  • 10. 1 0 grid-template-rows / grid-template-columns Defines the columns and rows of the grid with a space separated list of value. Values represent track size and can be a px length, percentage, or fraction of free space. Optional names can be given to the generated lines. grid-template-columns: 40px 50px 1fr 2fr; grid-column-gap / grid-row-gap Defines the space between grid tracks. grid-column-gap: 10px; grid-row-gap: 15px; grid-template-rows: [row1-start] 25% [row1-end] 100px [third-line] auto [last-line]; Repeat and minmax functions can also be used for more complex layouts. grid-template-rows: repeat(4, minmax(20px, 50px) 100px);
  • 11. 1 1 justify-items / align-items Justify-items aligns a grid items on the row axis, align-items aligns items on the column axis, inside grid cells. Values can be start, end, center, or stretch (default). justify-self: start; justify-self: center; align-self: end; align-self: stretch; justify-content / align-content Sometimes the total size of your grid might be less than the size of its grid container. This could happen if all of your grid items are sized with non-flexible units like px. Justify-content will align the grid on the row axis and align-content will align the grid on the column axis. Values can be start, end, center, stretch, space-around, space-between, space-evenly. justify-content: start; justify-content: center; align-content: space-around; align-content: space-evenly;
  • 13. 1 3 grid-column-start / grid-column-end / grid-row-start / grid-row-end Determines a grid item’s location within the grid by referring to specific grid lines. Value can be a number or name referring to a grid line, “span <number | name>” to span until specified line is hit, or auto. grid-column-start: 1; grid-column-end: span col4-start; grid-row-start: 2 grid-row-end: span 2 justify-self / align-self Justify-self aligns a grid item on the row axis, align-self aligns on the column axis. Values can be start, end, center, or stretch (default). justify-self: start; justify-self: center; align-self: end; align-self: stretch;
  • 15. 1 5 grid-auto-flow If you have grid items that you don't explicitly place on the grid, the auto-placement algorithm kicks in to automatically place the items. This property controls how the auto-placement algorithm works. It’s similar to flex-direction but with one special super power. grid-auto-flow: row; grid-auto-flow: column; grid-auto-flow: dense;
  • 17. 1 7 grid-template-areas / grid-area Defines a grid template by referencing the names of the grid areas which are specified with the grid-area property. Repeating the name of a grid area causes the content to span those cells. A period signifies an empty cell. The syntax itself provides a visualization of the structure of the grid. .item-a { grid-area: header; } .item-b { grid-area: main; } .item-c { grid-area: sidebar; } .item-d { grid-area: footer; } .container { grid-template-columns: 50px 50px 50px 50px; grid-template-rows: auto; grid-template-areas: "header header header header" "main main . sidebar" "footer footer footer footer"; }
  • 18. 1 8
  • 19. 1 9 .header { grid-area: header; } .main { grid-area: main; } .sidebar { grid-area: sidebar; } .footer { grid-area: footer; } .container { display: grid; grid-template-columns: 50px 50px 50px 50px; grid-template-rows: auto; grid-template-areas: "header header header header" "main main . sidebar" "footer footer footer footer"; }
  • 20. 2 0 .header { grid-area: header; } .main { grid-area: main; } .sidebar { grid-area: sidebar; } .footer { grid-area: footer; } .container { display: grid; grid-template-columns: 50px 50px 50px 50px; grid-template-rows: auto; grid-template-areas: "header header header header" "main main . sidebar" "footer footer footer footer"; } <div class="container"> <header class="header">Header</header> <main class="main">Main</main> <aside class="sidebar">Sidebar</aside> <footer class="footer">Footer</footer> </div>
  • 21. 2 1 Table Layout Grid Frameworks CSS Grid
  • 23. 2 3
  • 24. 2 4 .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); grid-gap: 30px; max-width: 960px; margin: 0 auto 30px; }
  • 25. 2 5 .container { grid-template-columns: 1fr 1fr; grid-template-rows: auto; grid-template-areas: "header header" "main main” “sidebar footer”; @media (——medium-screen) { grid-template-columns: 1fr 1fr 1fr 1fr; grid-template-areas: "header header header header" "main main . sidebar" "footer footer footer footer"; } }
  • 27. 2 7
  • 28. But what about Flex? 2 8
  • 29. 2 9 “The main idea behind the flex layout is to give the container the ability to alter its items’ width/height (and order) to best fill the available space (mostly to accommodate to all kind of display devices and screen sizes).” — Chris Coyier
  • 30. 3 0 • Flex is one dimensional. Grid is two dimensional. • A core difference is that Grid’s approach is layout- first while Flexbox’ approach is content-first. • If you want to define a layout as a row or a column, that flexes based on the content inside, then you probably need flexbox. • If you want to define a grid and fit content into it in two dimensions  then  you probably need grid.
  • 31. But what about Table? 3 1
  • 32. 3 2 Still use tables …but for tables