SlideShare a Scribd company logo
SIMONE LELLI
UI Designer & Developer @ Objectway
I like drawing, coding and cooking…
...COOKING?
YES! WE'RE GOING TO COOK AMAZING
LAYOUTS!
CSS GRID: WHY I'M ENTHUSIAST
I was a graphic designer
converted to web.
I love UI design and development.
CREATIVITY VS "FORCED" LAYOUT SOLUTIONS
-.-
Tables
Inline blocks
Floats
Flexbox
They are all hacks like this: it looks like an hamburger... but it is a veggie-burger...
...IF YOU WANT A REAL BURGER...
...YOU HAVE TO TAKE A STEP TO THE FUTURE!
Grids of Tomorrow: CSS Grid Layout
WHY SHOULD I LEARN IT TODAY?
TO BE COOL :)
TO DRIVE YOUR TEAM TOMORROW!
WHAT IS IT CSS GRID LAYOUT
MODULE?
Two-dimensional grid layout system
You can use media queries
You can order child elements as you want
HOW CAN I TRY IT NOW?
CHROME
chrome://flags/#enable-experimental-web-platform-
features
FIREFOX
set true layout.css.grid.enabled inside about:config
IE 10-11, EDGE
-ms- prefix early implementation (with some differences)
CSS GRID LAYOUT
TERMINOLOGY
GRID LINES
They can be referred to by numbers or they can be named.
GRID TRACK
The space between two tracks (horizontal or vertical)
GRID CELL
The smallest unit of the grid (space between four tracks).
It's something like a table cell.
GRID AREA
Any area bounded by four lines: it may contain different grid
cells.
GRID GUTTERS
Useful for cases with regular gutter sizes.
DEFINE THE GRID
A grid is defined by a new value of display property:
display: grid
HTML
Define a container with 6 child elements
<div class="grid-wrapper">
<div class="item a">A</div>
<div class="item b">B</div>
<div class="item c">C</div>
<div class="item d">D</div>
<div class="item e">E</div>
<div class="item f">F</div>
</div>
CSS
Defines a grid of 5 columns and 3 rows with different size
.grid-wrapper {
display: grid;
grid-template-columns: 30% 5% 30% 5% 30%;
grid-template-rows: 200px 20px 200px;
}
A B C D E
F
Auto-placement: each item fill the first available cell
but we don't want items inside gutter columns.
HOW TO PUT EACH ITEM IN THE RIGHT PLACE
.a {
grid-column-start: 1;
grid-column-end: 2;
grid-row-start: 1;
grid-row-end: 2;
}
/* SHORTHAND */
.a {
grid-column: 1/2;
grid-row: 1/2;
}
A B C
D E F
Now each item is placed in the right place.
A grid area can span as many cells you want…
A B
C D
A
B
C D
…in all directions and position…
A
BC D
E
Place items where you want! No order problems or
limitations :)
GRID GUTTERS
A B
C D
.table {
grid-row-gap: 20px;
grid-column-gap: 20px;
}
/* Shorthand: row, column */
.table {
grid-gap: 20px 20px;
}
SOMETHING MORE...
You can span a grid area trough cells by lines numbers or
with span keyword: with span you can say "start at line 1
and span 4 lines".
.item {
grid-column: 1 / span 4;
}
/* IS THE SAME OF */
.item {
grid-column: 1 / 5;
}
NAMED LINES
.grid-wrapper {
display: grid;
grid-template-columns: [col1-start] 200px [col1-end] 15px [col2-start
grid-template-rows: [row1-start] 200px [row1-end] 15px [row2-start]
}
POSITIONING ITEMS USING NAMED
LINES
.item.a {
display: grid;
grid-column: col1-start / col1-end;
grid-row: row1-start / row1-end;
}
MAGIC AREAS!
Header
Content
Primary
sidebar
Secondary
sidebar
Footer
Define named areas:
each item is assoaciated to a named area
.header {grid-area: header;}
.content {grid-area: content;}
.sidebar-a {grid-area: sidebar-a;}
.sidebar-b {grid-area: sidebar-b;}
.footer {grid-area: footer;}
Define grid and place named areas
something like ASCII-art!
.grid-wrapper {
display: grid;
grid-template-columns: 30% 5% 30% 5% 30%;
grid-template-rows: 200px 20px 200px;
grid-template-areas:
"header header header header header"
". . . . ."
"sidebar-a . content . sidebar-b"
". . . . ."
"footer footer footer footer footer"
}
FUNNY CODE, PERFECT RESULT
Header
Content
Primary
sidebar
Secondary
sidebar
Footer
VERY EASY TO CHANGE!
Header
Content
Primary
sidebar
Secondary sidebar Footer
.grid-wrapper.change {
grid-template-areas:
"sidebar-a . content content content"
". . . . ."
"sidebar-b sidebar-b sidebar-b . footer"
". . . . ."
"header header header header header"
}
REPEAT
ANOTHER USEFUL FEATURE
EASY REPEAT A COLUMN/ROW PATTERN AS MANY TIMES
YOU WANT!
.grid-wrapper {
display: grid;
grid-template-columns: repeat(12, [gutter] 10px [col] 1fr);
grid-template-row: repeat(24, [gutter] 10px [row] 80px);
}
THE "FR" UNIT
The fr unit (fraction of available space) can be used for grid-
rows and grid-columns values.
It works as percentages for available space when fixed-sized
and content-based columns/rows have taken their space.
Bye bye Bootstrap,
bye bye Foundation...
ONE MORE FUNNY THING…
OVERLAP
A B C
D F
G
E
control overlaps with z-index
NEXT STEP: NESTED GRIDS
Header
SUB-GRID
SUB-GRID CONTENT
SUB-GRID FOOTER
SUB-GRID
SIDEBAR
Primary
sidebar
Secondary
sidebar
Footer
Outer grid contains another grid defined by display: grid
property. Nested grid is independent by parent.
Nested grids can't inherit column widths from the parent.
. . .
grid: subgrid can do it
but actually is not supported by browsers.
Subgird feature is at-risk
and may be dropped during the CR period.
RESPONSIVE DESIGN
CSS grids can be fully managed inside media queries:
you have great control and unbelievable possibilities for
web layouts.
Redefine elements position and size is very easy.
If you want you could also redefine your grid.
!!! WOOOOOOOOOOOOOOOW !!!
CSS GRID LAYOUT
VS
FLEXBOX
CSS GRID LAYOUT + FLEXBOX
Grid is the best for complex page layouts
Grid is two-dimensional and supports non-linear design
Flexbox is the ideal solution for small page components
Flexbox is one-dimensional and supports linear design;
remember that it works on axis (column and row
direction).
CSS Grid avoids redundant markup!
A WELL-BALANCED MIX OF GRID AND FLEX
IS THE KEY OF BETTER PERFORMANCE.
THAT'S COOL, BUT IN REALITY?
CHROME has the most advanced implementation (Blink).
SAFARI is close to Chrome implementation, prefixed -webkit
on nightlies.
FIREFOX is in development.
IE10+ & EDGE have a working but outdated implementation.
The update to current spec is high priority in backlog.
STATE OF THE SPECIFICATION
Currently Working Dra Level 1: 17 September 2015
Plans to move it forward to Last Call Working Dra
before CR.
USEFUL LINKS
W3C Working Dra
https://www.w3.org/TR/css-grid-1
W3C Editor's Dra
https://dra s.csswg.org/css-grid-1
Polyfill (by Fremy Company)
https://github.com/FremyCompany/css-grid-polyfill
Codepen examples: , ,1 2 3
ENJOY IT!
Thank you ;)
Characters in GIFs are of the respective owners. I'm sorry if I broke some copyright but it wasn't for commercial purposes.

More Related Content

PDF
The New CSS Layout - Dutch PHP Conference
PDF
CSS Day: CSS Grid Layout
PDF
An Event Apart SF: CSS Grid Layout
PDF
Devoxx Belgium: CSS Grid Layout
PDF
An Event Apart Nashville: CSS Grid Layout
PDF
But what about old browsers?
PDF
Introduction to CSS Grid Layout
PDF
The New CSS Layout - Dutch PHP Conference
CSS Day: CSS Grid Layout
An Event Apart SF: CSS Grid Layout
Devoxx Belgium: CSS Grid Layout
An Event Apart Nashville: CSS Grid Layout
But what about old browsers?
Introduction to CSS Grid Layout

What's hot (20)

PDF
The New CSS Layout - dotCSS
PDF
CSS Grid Layout for Topconf, Linz
PDF
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
PDF
CSS Grid Layout. Implementation status and roadmap (Webkit Contributors Meeti...
PDF
CSS Grid Layout
PDF
CSS Grid Layout: An Event Apart Boston 2016
PPTX
Introducing CSS Grid
PDF
Fluent: Making Sense of the New CSS Layout
PDF
Future Layout & Performance
PDF
Flexbox and Grid Layout
PDF
Flexbox and Grid Layout
PDF
Frontend United: Start using CSS Grid Layout today!
PDF
World of CSS Grid
PDF
CSS Grid Layout Introduction
PDF
Grid and Flexbox - Smashing Conf SF
PDF
Render Conf: Start using CSS Grid Layout Today
PDF
CSS Grid Layout - All Things Open
PDF
Talk Web Design: Get Ready For CSS Grid Layout
PDF
AEA Chicago CSS Grid Layout
PDF
Introducing CSS Grid Layout
The New CSS Layout - dotCSS
CSS Grid Layout for Topconf, Linz
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
CSS Grid Layout. Implementation status and roadmap (Webkit Contributors Meeti...
CSS Grid Layout
CSS Grid Layout: An Event Apart Boston 2016
Introducing CSS Grid
Fluent: Making Sense of the New CSS Layout
Future Layout & Performance
Flexbox and Grid Layout
Flexbox and Grid Layout
Frontend United: Start using CSS Grid Layout today!
World of CSS Grid
CSS Grid Layout Introduction
Grid and Flexbox - Smashing Conf SF
Render Conf: Start using CSS Grid Layout Today
CSS Grid Layout - All Things Open
Talk Web Design: Get Ready For CSS Grid Layout
AEA Chicago CSS Grid Layout
Introducing CSS Grid Layout
Ad

Viewers also liked (20)

PDF
ES2015 New Features
PDF
The Great State of Design with CSS Grid Layout and Friends
PDF
CSS Grid layout - De volta para o futuro
PDF
CSS from the future
PPTX
Page layout & design task 2
PDF
Writ Petition Criminal NO.......of 2017 vide D.NO.3913 against Registrar Supr...
PPTX
Культурна Адаптація
PDF
Optimize your workflow
PDF
CSS Grid Layout
PPTX
Metodiskā darba aptauja par 2016. gadu
PDF
Appeal against Lodgment Order of Registrar SCI under Order XV Rule 5 of SCI R...
PDF
CSS Grid Layout from the inside out (HTML5DevConf Autumn 2015)
PDF
CSS Grid Layout w/ Blueprint CSS
PDF
Grid system introduction
DOCX
ТАСО 2016
PDF
Post-Modern CSS: Start learning CSS Grid, Flexbox and other new properties
PDF
The Best Practices of Symantec Code Signing - RapidSSLonline
PPTX
Presentation2
PDF
Layout, principles
DOCX
Task 3B evaluation of final desgin
ES2015 New Features
The Great State of Design with CSS Grid Layout and Friends
CSS Grid layout - De volta para o futuro
CSS from the future
Page layout & design task 2
Writ Petition Criminal NO.......of 2017 vide D.NO.3913 against Registrar Supr...
Культурна Адаптація
Optimize your workflow
CSS Grid Layout
Metodiskā darba aptauja par 2016. gadu
Appeal against Lodgment Order of Registrar SCI under Order XV Rule 5 of SCI R...
CSS Grid Layout from the inside out (HTML5DevConf Autumn 2015)
CSS Grid Layout w/ Blueprint CSS
Grid system introduction
ТАСО 2016
Post-Modern CSS: Start learning CSS Grid, Flexbox and other new properties
The Best Practices of Symantec Code Signing - RapidSSLonline
Presentation2
Layout, principles
Task 3B evaluation of final desgin
Ad

Similar to Grids of Tomorrow: CSS Grid Layout (20)

PDF
CSS3 Layout
PPTX
Css Grid Layout - A Short Introduction - Part 1
PDF
The Grid - The Future of CSS Layout
PDF
Web I - 07 - CSS Frameworks
PDF
CSS Grid Layout
PDF
Introduction to CSS Grid
PDF
The Future State of Layout
PDF
Laying out the future with grid & flexbox - Smashing Conf Freiburg
PPT
17523630.ppt
PDF
Evergreen websites for Evergreen browsers
PPTX
Full Stack Development CSS_Layouts,Grid,FlexboxPPT.pptx
PDF
The Future of CSS Layout
PPTX
2D Page Layout
PPTX
CSS Flexbox and Grid: The future of website layouts - DN Scrum Breakfast - Au...
PDF
DevFest Nantes - Start Using CSS Grid Layout today
PDF
Solving Layout Problems with CSS Grid & Friends - DevFest17
PDF
Introduction to CSS Grid
PDF
What I discovered about layout vis CSS Grid
PDF
View Source London: Solving Layout Problems with CSS Grid & Friends
PDF
Start Using CSS Grid Layout Today - RuhrJS
CSS3 Layout
Css Grid Layout - A Short Introduction - Part 1
The Grid - The Future of CSS Layout
Web I - 07 - CSS Frameworks
CSS Grid Layout
Introduction to CSS Grid
The Future State of Layout
Laying out the future with grid & flexbox - Smashing Conf Freiburg
17523630.ppt
Evergreen websites for Evergreen browsers
Full Stack Development CSS_Layouts,Grid,FlexboxPPT.pptx
The Future of CSS Layout
2D Page Layout
CSS Flexbox and Grid: The future of website layouts - DN Scrum Breakfast - Au...
DevFest Nantes - Start Using CSS Grid Layout today
Solving Layout Problems with CSS Grid & Friends - DevFest17
Introduction to CSS Grid
What I discovered about layout vis CSS Grid
View Source London: Solving Layout Problems with CSS Grid & Friends
Start Using CSS Grid Layout Today - RuhrJS

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Electronic commerce courselecture one. Pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
KodekX | Application Modernization Development
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Sensors and Actuators in IoT Systems using pdf
PDF
Advanced IT Governance
PDF
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
20250228 LYD VKU AI Blended-Learning.pptx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Empathic Computing: Creating Shared Understanding
Electronic commerce courselecture one. Pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
Per capita expenditure prediction using model stacking based on satellite ima...
Advanced Soft Computing BINUS July 2025.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
KodekX | Application Modernization Development
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Sensors and Actuators in IoT Systems using pdf
Advanced IT Governance
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
Chapter 3 Spatial Domain Image Processing.pdf
Understanding_Digital_Forensics_Presentation.pptx

Grids of Tomorrow: CSS Grid Layout

  • 1. SIMONE LELLI UI Designer & Developer @ Objectway
  • 2. I like drawing, coding and cooking… ...COOKING?
  • 3. YES! WE'RE GOING TO COOK AMAZING LAYOUTS!
  • 4. CSS GRID: WHY I'M ENTHUSIAST I was a graphic designer converted to web. I love UI design and development. CREATIVITY VS "FORCED" LAYOUT SOLUTIONS -.-
  • 5. Tables Inline blocks Floats Flexbox They are all hacks like this: it looks like an hamburger... but it is a veggie-burger...
  • 6. ...IF YOU WANT A REAL BURGER...
  • 7. ...YOU HAVE TO TAKE A STEP TO THE FUTURE!
  • 9. WHY SHOULD I LEARN IT TODAY?
  • 11. TO DRIVE YOUR TEAM TOMORROW!
  • 12. WHAT IS IT CSS GRID LAYOUT MODULE? Two-dimensional grid layout system You can use media queries You can order child elements as you want
  • 13. HOW CAN I TRY IT NOW? CHROME chrome://flags/#enable-experimental-web-platform- features FIREFOX set true layout.css.grid.enabled inside about:config IE 10-11, EDGE -ms- prefix early implementation (with some differences)
  • 15. GRID LINES They can be referred to by numbers or they can be named.
  • 16. GRID TRACK The space between two tracks (horizontal or vertical)
  • 17. GRID CELL The smallest unit of the grid (space between four tracks). It's something like a table cell.
  • 18. GRID AREA Any area bounded by four lines: it may contain different grid cells.
  • 19. GRID GUTTERS Useful for cases with regular gutter sizes.
  • 20. DEFINE THE GRID A grid is defined by a new value of display property: display: grid
  • 21. HTML Define a container with 6 child elements <div class="grid-wrapper"> <div class="item a">A</div> <div class="item b">B</div> <div class="item c">C</div> <div class="item d">D</div> <div class="item e">E</div> <div class="item f">F</div> </div>
  • 22. CSS Defines a grid of 5 columns and 3 rows with different size .grid-wrapper { display: grid; grid-template-columns: 30% 5% 30% 5% 30%; grid-template-rows: 200px 20px 200px; }
  • 23. A B C D E F Auto-placement: each item fill the first available cell but we don't want items inside gutter columns.
  • 24. HOW TO PUT EACH ITEM IN THE RIGHT PLACE .a { grid-column-start: 1; grid-column-end: 2; grid-row-start: 1; grid-row-end: 2; } /* SHORTHAND */ .a { grid-column: 1/2; grid-row: 1/2; }
  • 25. A B C D E F Now each item is placed in the right place.
  • 26. A grid area can span as many cells you want… A B C D
  • 27. A B C D …in all directions and position…
  • 28. A BC D E Place items where you want! No order problems or limitations :)
  • 29. GRID GUTTERS A B C D .table { grid-row-gap: 20px; grid-column-gap: 20px; } /* Shorthand: row, column */ .table { grid-gap: 20px 20px; }
  • 30. SOMETHING MORE... You can span a grid area trough cells by lines numbers or with span keyword: with span you can say "start at line 1 and span 4 lines". .item { grid-column: 1 / span 4; } /* IS THE SAME OF */ .item { grid-column: 1 / 5; }
  • 31. NAMED LINES .grid-wrapper { display: grid; grid-template-columns: [col1-start] 200px [col1-end] 15px [col2-start grid-template-rows: [row1-start] 200px [row1-end] 15px [row2-start] }
  • 32. POSITIONING ITEMS USING NAMED LINES .item.a { display: grid; grid-column: col1-start / col1-end; grid-row: row1-start / row1-end; }
  • 34. Define named areas: each item is assoaciated to a named area .header {grid-area: header;} .content {grid-area: content;} .sidebar-a {grid-area: sidebar-a;} .sidebar-b {grid-area: sidebar-b;} .footer {grid-area: footer;}
  • 35. Define grid and place named areas something like ASCII-art! .grid-wrapper { display: grid; grid-template-columns: 30% 5% 30% 5% 30%; grid-template-rows: 200px 20px 200px; grid-template-areas: "header header header header header" ". . . . ." "sidebar-a . content . sidebar-b" ". . . . ." "footer footer footer footer footer" }
  • 36. FUNNY CODE, PERFECT RESULT Header Content Primary sidebar Secondary sidebar Footer
  • 37. VERY EASY TO CHANGE! Header Content Primary sidebar Secondary sidebar Footer
  • 38. .grid-wrapper.change { grid-template-areas: "sidebar-a . content content content" ". . . . ." "sidebar-b sidebar-b sidebar-b . footer" ". . . . ." "header header header header header" }
  • 40. EASY REPEAT A COLUMN/ROW PATTERN AS MANY TIMES YOU WANT! .grid-wrapper { display: grid; grid-template-columns: repeat(12, [gutter] 10px [col] 1fr); grid-template-row: repeat(24, [gutter] 10px [row] 80px); }
  • 41. THE "FR" UNIT The fr unit (fraction of available space) can be used for grid- rows and grid-columns values. It works as percentages for available space when fixed-sized and content-based columns/rows have taken their space.
  • 42. Bye bye Bootstrap, bye bye Foundation...
  • 43. ONE MORE FUNNY THING… OVERLAP
  • 44. A B C D F G E control overlaps with z-index
  • 45. NEXT STEP: NESTED GRIDS Header SUB-GRID SUB-GRID CONTENT SUB-GRID FOOTER SUB-GRID SIDEBAR Primary sidebar Secondary sidebar Footer Outer grid contains another grid defined by display: grid property. Nested grid is independent by parent.
  • 46. Nested grids can't inherit column widths from the parent. . . . grid: subgrid can do it but actually is not supported by browsers. Subgird feature is at-risk and may be dropped during the CR period.
  • 47. RESPONSIVE DESIGN CSS grids can be fully managed inside media queries: you have great control and unbelievable possibilities for web layouts. Redefine elements position and size is very easy. If you want you could also redefine your grid.
  • 50. CSS GRID LAYOUT + FLEXBOX
  • 51. Grid is the best for complex page layouts Grid is two-dimensional and supports non-linear design Flexbox is the ideal solution for small page components Flexbox is one-dimensional and supports linear design; remember that it works on axis (column and row direction).
  • 52. CSS Grid avoids redundant markup!
  • 53. A WELL-BALANCED MIX OF GRID AND FLEX IS THE KEY OF BETTER PERFORMANCE.
  • 54. THAT'S COOL, BUT IN REALITY?
  • 55. CHROME has the most advanced implementation (Blink). SAFARI is close to Chrome implementation, prefixed -webkit on nightlies. FIREFOX is in development. IE10+ & EDGE have a working but outdated implementation. The update to current spec is high priority in backlog.
  • 56. STATE OF THE SPECIFICATION Currently Working Dra Level 1: 17 September 2015 Plans to move it forward to Last Call Working Dra before CR.
  • 57. USEFUL LINKS W3C Working Dra https://www.w3.org/TR/css-grid-1 W3C Editor's Dra https://dra s.csswg.org/css-grid-1 Polyfill (by Fremy Company) https://github.com/FremyCompany/css-grid-polyfill Codepen examples: , ,1 2 3
  • 58. ENJOY IT! Thank you ;) Characters in GIFs are of the respective owners. I'm sorry if I broke some copyright but it wasn't for commercial purposes.