SlideShare a Scribd company logo
1 of 58
Download to read offline
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!
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

What's hot

What's hot (20)

The New CSS Layout - dotCSS
The New CSS Layout - dotCSSThe New CSS Layout - dotCSS
The New CSS Layout - dotCSS
 
CSS Grid Layout for Topconf, Linz
CSS Grid Layout for Topconf, LinzCSS Grid Layout for Topconf, Linz
CSS Grid Layout for Topconf, Linz
 
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
 
CSS Grid Layout. Implementation status and roadmap (Webkit Contributors Meeti...
CSS Grid Layout. Implementation status and roadmap (Webkit Contributors Meeti...CSS Grid Layout. Implementation status and roadmap (Webkit Contributors Meeti...
CSS Grid Layout. Implementation status and roadmap (Webkit Contributors Meeti...
 
CSS Grid Layout
CSS Grid LayoutCSS Grid Layout
CSS Grid Layout
 
CSS Grid Layout: An Event Apart Boston 2016
CSS Grid Layout: An Event Apart Boston 2016CSS Grid Layout: An Event Apart Boston 2016
CSS Grid Layout: An Event Apart Boston 2016
 
Introducing CSS Grid
Introducing CSS GridIntroducing CSS Grid
Introducing CSS Grid
 
Fluent: Making Sense of the New CSS Layout
Fluent: Making Sense of the New CSS LayoutFluent: Making Sense of the New CSS Layout
Fluent: Making Sense of the New CSS Layout
 
Future Layout & Performance
Future Layout & PerformanceFuture Layout & Performance
Future Layout & Performance
 
Flexbox and Grid Layout
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid Layout
 
Flexbox and Grid Layout
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid Layout
 
Frontend United: Start using CSS Grid Layout today!
Frontend United: Start using CSS Grid Layout today!Frontend United: Start using CSS Grid Layout today!
Frontend United: Start using CSS Grid Layout today!
 
World of CSS Grid
World of CSS GridWorld of CSS Grid
World of CSS Grid
 
CSS Grid Layout Introduction
CSS Grid Layout IntroductionCSS Grid Layout Introduction
CSS Grid Layout Introduction
 
Grid and Flexbox - Smashing Conf SF
Grid and Flexbox - Smashing Conf SFGrid and Flexbox - Smashing Conf SF
Grid and Flexbox - Smashing Conf SF
 
Render Conf: Start using CSS Grid Layout Today
Render Conf: Start using CSS Grid Layout TodayRender Conf: Start using CSS Grid Layout Today
Render Conf: Start using CSS Grid Layout Today
 
CSS Grid Layout - All Things Open
CSS Grid Layout - All Things OpenCSS Grid Layout - All Things Open
CSS Grid Layout - All Things Open
 
Talk Web Design: Get Ready For CSS Grid Layout
Talk Web Design: Get Ready For CSS Grid LayoutTalk Web Design: Get Ready For CSS Grid Layout
Talk Web Design: Get Ready For CSS Grid Layout
 
AEA Chicago CSS Grid Layout
AEA Chicago CSS Grid LayoutAEA Chicago CSS Grid Layout
AEA Chicago CSS Grid Layout
 
Introducing CSS Grid Layout
Introducing CSS Grid LayoutIntroducing CSS Grid Layout
Introducing CSS Grid Layout
 

Viewers also liked

Page layout & design task 2
Page layout & design task 2Page layout & design task 2
Page layout & design task 2
Craig Cassidy
 
Task 3B evaluation of final desgin
Task 3B evaluation of final desginTask 3B evaluation of final desgin
Task 3B evaluation of final desgin
Gaetan Lundula
 

Viewers also liked (20)

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

Similar to Grids of Tomorrow: CSS Grid Layout

MW2011 Grid-based Web Design presentation
MW2011 Grid-based Web Design presentationMW2011 Grid-based Web Design presentation
MW2011 Grid-based Web Design presentation
Charlie Moad
 
Drupal Theming with CSS Frameworks (960grid)
Drupal Theming with CSS Frameworks (960grid)Drupal Theming with CSS Frameworks (960grid)
Drupal Theming with CSS Frameworks (960grid)
Ryan Cross
 

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

The Future State of Layout
The Future State of LayoutThe Future State of Layout
The Future State of Layout
 
Responsive Design: Out of the Box and Down the Rabbit Hole
Responsive Design: Out of the Box and Down the Rabbit HoleResponsive Design: Out of the Box and Down the Rabbit Hole
Responsive Design: Out of the Box and Down the Rabbit Hole
 
Start Using CSS Grid Layout Today - RuhrJS
Start Using CSS Grid Layout Today - RuhrJSStart Using CSS Grid Layout Today - RuhrJS
Start Using CSS Grid Layout Today - RuhrJS
 
MW2011 Grid-based Web Design presentation
MW2011 Grid-based Web Design presentationMW2011 Grid-based Web Design presentation
MW2011 Grid-based Web Design presentation
 
The Future of CSS Layout
The Future of CSS LayoutThe Future of CSS Layout
The Future of CSS Layout
 
Angular.js Directives for Interactive Web Applications
Angular.js Directives for Interactive Web ApplicationsAngular.js Directives for Interactive Web Applications
Angular.js Directives for Interactive Web Applications
 
Teams, styles and scalable applications
Teams, styles and scalable applicationsTeams, styles and scalable applications
Teams, styles and scalable applications
 
Step by Step Asp.Net GridView Tutorials
Step by Step Asp.Net GridView TutorialsStep by Step Asp.Net GridView Tutorials
Step by Step Asp.Net GridView Tutorials
 
2D Page Layout
2D Page Layout2D Page Layout
2D Page Layout
 
Fewd week7 slides
Fewd week7 slidesFewd week7 slides
Fewd week7 slides
 
Fewd week2 slides
Fewd week2 slidesFewd week2 slides
Fewd week2 slides
 
LESS
LESSLESS
LESS
 
Drupal Theming with CSS Frameworks (960grid)
Drupal Theming with CSS Frameworks (960grid)Drupal Theming with CSS Frameworks (960grid)
Drupal Theming with CSS Frameworks (960grid)
 
CSS- Smacss Design Rule
CSS- Smacss Design RuleCSS- Smacss Design Rule
CSS- Smacss Design Rule
 
INTRODUCTIONS OF CSS PART 2
INTRODUCTIONS OF CSS PART 2INTRODUCTIONS OF CSS PART 2
INTRODUCTIONS OF CSS PART 2
 
CSS Architecture - JSIL.pdf
CSS Architecture - JSIL.pdfCSS Architecture - JSIL.pdf
CSS Architecture - JSIL.pdf
 
Not Just a Pretty Face: How to design and build a cross-CMS CSS framework
Not Just a Pretty Face: How to design and build a cross-CMS CSS frameworkNot Just a Pretty Face: How to design and build a cross-CMS CSS framework
Not Just a Pretty Face: How to design and build a cross-CMS CSS framework
 
BEM Methodology — @Frontenders Ticino —17/09/2014
BEM Methodology — @Frontenders Ticino —17/09/2014BEM Methodology — @Frontenders Ticino —17/09/2014
BEM Methodology — @Frontenders Ticino —17/09/2014
 
Web I - 07 - CSS Frameworks
Web I - 07 - CSS FrameworksWeb I - 07 - CSS Frameworks
Web I - 07 - CSS Frameworks
 
What I discovered about layout vis CSS Grid
What I discovered about layout vis CSS GridWhat I discovered about layout vis CSS Grid
What I discovered about layout vis CSS Grid
 

Recently uploaded

Recently uploaded (20)

Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 

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!
  • 8.
  • 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.