SlideShare a Scribd company logo
CSS Grid vs.
Flexible Box
@evalica
Layout Evolution
● CSS2
● CSS3
CSS2.1
● no
●
CSS3 Level
Modules Timeline
Layout Specifications
Float Display Position Flex Grid
Launched 1996- 1996-2011- 2008-2011- 2009-2016-2018- 2012-2017-
Level CSS1 CSS1, CSS2.1 CSS2.1 CSS3, Lvl1 CSS3, Lvl1
Maturity REC REC REC CR CR
Syntax float:
none|left|right|
initial|inherit;
display:
none|inline|block|
List-item|
inline-block|table|
...;
position:
static|absolute|
Fixed|relative|
Sticky|initial|
inherit;
display: flex;
flex: flex-grow
flex-shrink
flex-basis|auto|
initial|inherit;
display: grid;
grid:
none|grid-template-
rows /
grid-template-colum
ns|grid-template-ar
eas|grid-template-r
ows /
[grid-auto-flow]
grid-auto-columns|[
grid-auto-flow]
grid-auto-rows /
grid-template-colum
ns|initial|inherit;
CR
REC
CSS Grid vs. Flexbox
Guides & Documentation
MDN: Flexbox
CSS Tricks Guide
MDN: Grid
CSS Tricks Guide
Screencasts Tutorials
Game Tutorials
Flexbox Froggy Grid Garden
Grid vs. Flex
● one direction
●
● direction-agnostic
● cannot overlap
Flexible Box
● two directions
●
● overlap
CSS Grid
Can I use?
Flexible Box
98.30% JUN 2019
@supports not ((display: flex) and (display: grid))
{
div {
float: left;
}
}
CR .
@supports (display: grid) {
.wrapper ul {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 20px;
}
}
Can I use?
CSS Grid
92.03% JUN 2019CR .
Basic Alternatives
Float GridFlex
<div class="container">
<div class="box a">A</div>
<div class="box b">B</div>
<div class="box c">C</div>
<div class="box d">D</div>
<div class="box e">E</div>
<div class="box f">F</div>
</div>
.container {
}
.box {
float: left;
margin: 5px;
width: 100px;
}
.container {
display: grid;
grid-gap: 10px;
grid-template-columns:
repeat(auto-fit, 100px);
}
.box {
}
.container {
display: flex;
flex-wrap: wrap;
}
.box {
flex-basis: 100px;
margin: 5px;
}
Firefox
Nightly
.a {
grid-column: 1 / 3;
grid-row: 1;
}
.b {
grid-column: 3;
grid-row: 1 / 3;
}
.c {
grid-column: 1;
grid-row: 2 / 4;
}
.a {
}
.b {
}
.c {
}
.container {
display: grid;
grid-gap: 10px;
grid-template-columns:
repeat(3, 100px);
}
Grid Overlap
.a {
grid-column: 1;
grid-row: 1;
}
.b {
grid-column: 2;
grid-row: 1;
}
.c {
grid-column: 3;
grid-row: 1;
}
Bootstrap 4 - FlexBootstrap 3 - Float
<div class="container">
<div class="row">
<div class="col-xs-4">A</div>
<div class="col-xs-4">B</div>
<div class="col-xs-4">C</div>
</div>
</div>
Grid
<div class="container">
<div class="row">
<div class="col">A</div>
<div class="col">B</div>
<div class="col">C</div>
</div>
</div>
<div class="container">
<div class="col">A</div>
<div class="col">B</div>
<div class="col">C</div>
</div>
.container {
display: grid;
grid-template-columns: repeat(12, 1fr);
grid-gap: 10px;
}
.col {
grid-column: span 4;
}
.row {
display: flex;
}
.col {
flex-basis: 0;
flex-grow: 1;
}
Nested Layout
Layouts
.header {
grid-area: H;
}
.panels.A {
grid-area: A;
}
.panels.B {
grid-area: B;
}
.content {
grid-area: C;
}
.footer {
grid-area: F;
}
<body>
<div class="header">H</div>
<div class="content">C</div>
<div class="panels A">A</div>
<div class="panels B">B</div>
<div class="footer">F</div>
</body>
Grid Areas - Easy Prototyping
body {
display: grid;
grid-template-columns: repeat(12, 1fr);
grid-template-rows: 1fr 4fr 1fr;
grid-template-areas:
"H H H H H H H H H H H H"
"A C C C C C C C C C C B"
"F F F F F F F F F F F F";
}
Layouts
4-134-12
Display: contents
<body>
<div class="header">H</div>
<div class="content">C</div>
<div class="panels A">A</div>
<div class="panels B">B</div>
<div class="footer">F</div>
</body>
<body>
<div class="header">H</div>
<div class="container">
<div class="container">
<div class="content">C</div>
<div class="panels A">A</div>
</div>
<div class="panels B">B</div>
</div>
<div class="footer">F</div>
</body>
.container {
display: contents;
}
Can I use?
display: contents
82.38% JUN 2019
ul, ol {
list-style: none;
display: contents;
}
WD .
.download-option {
display: grid;
grid-template-rows: subgrid;
grid-row: 1 / -1;
}
<div class="download-options">
<div class="download-option">
<div>...</div>
<h3>...</h3>
<ul><li>...</li></ul>
<p>...</p>
<div><a>...</a><a>...</a></div>
</div>
...
SubGrid - Cards Alignment
.download-options {
display: grid;
grid-template-rows: repeat(5, auto);
}
Can I use?
Subgrid
0.0% JUN 2019
.items {
display: grid;
grid-template-columns: subgrid;
grid-auto-rows: minmax(100px, auto);
}
WD .
●
●
●
●
●
●
Conclusions: Grid vs. Flex
Thank you
@evalica #iscss
References
● A Complete Guide to Flexbox
● A Complete Guide to Grid
● MDN: CSS layout
● MDN: Subgrid
● Grid by Example
● The Experimental Layouts Lab
● [Games] Grid Garden + Flexbox Froggy
● [Video] Flexbox vs. CSS Grid — Which is
Better?
● [Video] Hello Subgrid!
● [Video] CSS Grid: Moving From CSS
Frameworks To CSS Grid (2018 and beyond)
● CSS Grids — How Everyone Has Been
Building The Web Wrong Before 2018

More Related Content

What's hot (20)

PDF
HTML and CSS crash course!
Ana Cidre
 
PDF
An introduction to React.js
Emanuele DelBono
 
PPSX
Javascript variables and datatypes
Varun C M
 
PDF
World of CSS Grid
Elad Shechter
 
PPT
PHP - Introduction to Object Oriented Programming with PHP
Vibrant Technologies & Computers
 
PPTX
Bootstrap - Basics
FirosK2
 
PDF
Introduction to Redux
Ignacio Martín
 
PPTX
JAVASCRIPT PPT [Autosaved].pptx
AchieversIT
 
PPTX
Bootstrap 5 ppt
Mallikarjuna G D
 
PPTX
Css animation
Aaron King
 
PPTX
Css selectors
Parth Trivedi
 
PPT
Introduction to JavaScript (1).ppt
MuhammadRehan856177
 
PPTX
jQuery
Dileep Mishra
 
PDF
jQuery for beginners
Arulmurugan Rajaraman
 
PPTX
Html5 and-css3-overview
Jacob Nelson
 
PDF
Introduction to CSS3
Doris Chen
 
PPT
JQuery introduction
NexThoughts Technologies
 
PPTX
ReactJS presentation.pptx
DivyanshGupta922023
 
PPT
JavaScript - An Introduction
Manvendra Singh
 
HTML and CSS crash course!
Ana Cidre
 
An introduction to React.js
Emanuele DelBono
 
Javascript variables and datatypes
Varun C M
 
World of CSS Grid
Elad Shechter
 
PHP - Introduction to Object Oriented Programming with PHP
Vibrant Technologies & Computers
 
Bootstrap - Basics
FirosK2
 
Introduction to Redux
Ignacio Martín
 
JAVASCRIPT PPT [Autosaved].pptx
AchieversIT
 
Bootstrap 5 ppt
Mallikarjuna G D
 
Css animation
Aaron King
 
Css selectors
Parth Trivedi
 
Introduction to JavaScript (1).ppt
MuhammadRehan856177
 
jQuery for beginners
Arulmurugan Rajaraman
 
Html5 and-css3-overview
Jacob Nelson
 
Introduction to CSS3
Doris Chen
 
JQuery introduction
NexThoughts Technologies
 
ReactJS presentation.pptx
DivyanshGupta922023
 
JavaScript - An Introduction
Manvendra Singh
 

Similar to CSS Grid vs. Flexbox (20)

PDF
An Event Apart SF: CSS Grid Layout
Rachel Andrew
 
PDF
CSS Grid Layout for Topconf, Linz
Rachel Andrew
 
PDF
Devoxx Belgium: CSS Grid Layout
Rachel Andrew
 
PDF
An Event Apart Nashville: CSS Grid Layout
Rachel Andrew
 
PDF
CSS Grid Layout
Rachel Andrew
 
PDF
Evergreen websites for Evergreen browsers
Rachel Andrew
 
PDF
Introduction to CSS Grid Layout
Rachel Andrew
 
PDF
What I discovered about layout vis CSS Grid
Rachel Andrew
 
PDF
CSS3 Layout
Zoe Gillenwater
 
PDF
Frontend United: Start using CSS Grid Layout today!
Rachel Andrew
 
PDF
View Source London: Solving Layout Problems with CSS Grid & Friends
Rachel Andrew
 
PDF
CSS Grid Layout - All Things Open
Rachel Andrew
 
PDF
CSS Grid Layout
All Things Open
 
PDF
New CSS Layout Meets the Real World
Rachel Andrew
 
PDF
Solving Layout Problems with CSS Grid & Friends - DevFest17
Rachel Andrew
 
PDF
CSS Grid Layout for Frontend NE
Rachel Andrew
 
PDF
An Event Apart DC - New CSS Layout meets the Real World
Rachel Andrew
 
PDF
Grids of Tomorrow: CSS Grid Layout
Simone Lelli
 
PDF
New CSS Meets the Real World
Rachel Andrew
 
PDF
Start Using CSS Grid Layout Today - RuhrJS
Rachel Andrew
 
An Event Apart SF: CSS Grid Layout
Rachel Andrew
 
CSS Grid Layout for Topconf, Linz
Rachel Andrew
 
Devoxx Belgium: CSS Grid Layout
Rachel Andrew
 
An Event Apart Nashville: CSS Grid Layout
Rachel Andrew
 
CSS Grid Layout
Rachel Andrew
 
Evergreen websites for Evergreen browsers
Rachel Andrew
 
Introduction to CSS Grid Layout
Rachel Andrew
 
What I discovered about layout vis CSS Grid
Rachel Andrew
 
CSS3 Layout
Zoe Gillenwater
 
Frontend United: Start using CSS Grid Layout today!
Rachel Andrew
 
View Source London: Solving Layout Problems with CSS Grid & Friends
Rachel Andrew
 
CSS Grid Layout - All Things Open
Rachel Andrew
 
CSS Grid Layout
All Things Open
 
New CSS Layout Meets the Real World
Rachel Andrew
 
Solving Layout Problems with CSS Grid & Friends - DevFest17
Rachel Andrew
 
CSS Grid Layout for Frontend NE
Rachel Andrew
 
An Event Apart DC - New CSS Layout meets the Real World
Rachel Andrew
 
Grids of Tomorrow: CSS Grid Layout
Simone Lelli
 
New CSS Meets the Real World
Rachel Andrew
 
Start Using CSS Grid Layout Today - RuhrJS
Rachel Andrew
 
Ad

More from Ecaterina Moraru (Valica) (20)

PDF
UI/UX Tips & Tricks for developers - FOSDEM2020
Ecaterina Moraru (Valica)
 
PDF
UI/UX Tips & Tricks for developers
Ecaterina Moraru (Valica)
 
PDF
Sketching Session
Ecaterina Moraru (Valica)
 
PDF
Designing in the open
Ecaterina Moraru (Valica)
 
PDF
XWiki Skin 10.x+ ideas
Ecaterina Moraru (Valica)
 
PDF
Difficulties in having more designers participate in Open Source
Ecaterina Moraru (Valica)
 
PDF
CSS Variables — Native reusable custom properties
Ecaterina Moraru (Valica)
 
PDF
Design proposals status 9.x
Ecaterina Moraru (Valica)
 
PDF
What's new in XWiki 8.x and half of 9.x
Ecaterina Moraru (Valica)
 
PDF
Expectations from Open Source Designers
Ecaterina Moraru (Valica)
 
PDF
Success stats from OSD community
Ecaterina Moraru (Valica)
 
PDF
Future of XWiki Skins
Ecaterina Moraru (Valica)
 
PDF
Design process in an Open Community
Ecaterina Moraru (Valica)
 
PDF
XWiki Usability Testing Sessions
Ecaterina Moraru (Valica)
 
PDF
About XWiki.org
Ecaterina Moraru (Valica)
 
PDF
Evolution of CSS
Ecaterina Moraru (Valica)
 
ODP
XWiki Improvements Review (ver 2.4 - 5.1)
Ecaterina Moraru (Valica)
 
PDF
Interconectarea Semantica A Datelor In Contextul Managementului Informatiilor...
Ecaterina Moraru (Valica)
 
PDF
Tehnici De Tip Mashup Pentru Interactiuni Web In Sisteme Informationale Geogr...
Ecaterina Moraru (Valica)
 
UI/UX Tips & Tricks for developers - FOSDEM2020
Ecaterina Moraru (Valica)
 
UI/UX Tips & Tricks for developers
Ecaterina Moraru (Valica)
 
Sketching Session
Ecaterina Moraru (Valica)
 
Designing in the open
Ecaterina Moraru (Valica)
 
XWiki Skin 10.x+ ideas
Ecaterina Moraru (Valica)
 
Difficulties in having more designers participate in Open Source
Ecaterina Moraru (Valica)
 
CSS Variables — Native reusable custom properties
Ecaterina Moraru (Valica)
 
Design proposals status 9.x
Ecaterina Moraru (Valica)
 
What's new in XWiki 8.x and half of 9.x
Ecaterina Moraru (Valica)
 
Expectations from Open Source Designers
Ecaterina Moraru (Valica)
 
Success stats from OSD community
Ecaterina Moraru (Valica)
 
Future of XWiki Skins
Ecaterina Moraru (Valica)
 
Design process in an Open Community
Ecaterina Moraru (Valica)
 
XWiki Usability Testing Sessions
Ecaterina Moraru (Valica)
 
About XWiki.org
Ecaterina Moraru (Valica)
 
Evolution of CSS
Ecaterina Moraru (Valica)
 
XWiki Improvements Review (ver 2.4 - 5.1)
Ecaterina Moraru (Valica)
 
Interconectarea Semantica A Datelor In Contextul Managementului Informatiilor...
Ecaterina Moraru (Valica)
 
Tehnici De Tip Mashup Pentru Interactiuni Web In Sisteme Informationale Geogr...
Ecaterina Moraru (Valica)
 
Ad

Recently uploaded (20)

PDF
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
PDF
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
PDF
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
PDF
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
PDF
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
Wondershare Filmora Crack Free Download 2025
josanj305
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
PDF
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
PDF
Next Generation AI: Anticipatory Intelligence, Forecasting Inflection Points ...
dleka294658677
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PDF
Draugnet: Anonymous Threat Reporting for a World on Fire
treyka
 
PDF
Deploy Faster, Run Smarter: Learn Containers with QNAP
QNAP Marketing
 
PDF
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
PDF
Kubernetes - Architecture & Components.pdf
geethak285
 
PDF
Sound the Alarm: Detection and Response
VICTOR MAESTRE RAMIREZ
 
PPTX
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
Wondershare Filmora Crack Free Download 2025
josanj305
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
Dev Dives: Accelerating agentic automation with Autopilot for Everyone
UiPathCommunity
 
Next Generation AI: Anticipatory Intelligence, Forecasting Inflection Points ...
dleka294658677
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
Draugnet: Anonymous Threat Reporting for a World on Fire
treyka
 
Deploy Faster, Run Smarter: Learn Containers with QNAP
QNAP Marketing
 
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
Kubernetes - Architecture & Components.pdf
geethak285
 
Sound the Alarm: Detection and Response
VICTOR MAESTRE RAMIREZ
 
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 

CSS Grid vs. Flexbox

  • 1. CSS Grid vs. Flexible Box @evalica
  • 3. ● CSS2 ● CSS3 CSS2.1 ● no ● CSS3 Level
  • 5. Layout Specifications Float Display Position Flex Grid Launched 1996- 1996-2011- 2008-2011- 2009-2016-2018- 2012-2017- Level CSS1 CSS1, CSS2.1 CSS2.1 CSS3, Lvl1 CSS3, Lvl1 Maturity REC REC REC CR CR Syntax float: none|left|right| initial|inherit; display: none|inline|block| List-item| inline-block|table| ...; position: static|absolute| Fixed|relative| Sticky|initial| inherit; display: flex; flex: flex-grow flex-shrink flex-basis|auto| initial|inherit; display: grid; grid: none|grid-template- rows / grid-template-colum ns|grid-template-ar eas|grid-template-r ows / [grid-auto-flow] grid-auto-columns|[ grid-auto-flow] grid-auto-rows / grid-template-colum ns|initial|inherit; CR REC
  • 7. Guides & Documentation MDN: Flexbox CSS Tricks Guide MDN: Grid CSS Tricks Guide
  • 11. ● one direction ● ● direction-agnostic ● cannot overlap Flexible Box
  • 12. ● two directions ● ● overlap CSS Grid
  • 13. Can I use? Flexible Box 98.30% JUN 2019 @supports not ((display: flex) and (display: grid)) { div { float: left; } } CR .
  • 14. @supports (display: grid) { .wrapper ul { display: grid; grid-template-columns: repeat(3, 1fr); grid-gap: 20px; } } Can I use? CSS Grid 92.03% JUN 2019CR .
  • 15. Basic Alternatives Float GridFlex <div class="container"> <div class="box a">A</div> <div class="box b">B</div> <div class="box c">C</div> <div class="box d">D</div> <div class="box e">E</div> <div class="box f">F</div> </div> .container { } .box { float: left; margin: 5px; width: 100px; } .container { display: grid; grid-gap: 10px; grid-template-columns: repeat(auto-fit, 100px); } .box { } .container { display: flex; flex-wrap: wrap; } .box { flex-basis: 100px; margin: 5px; }
  • 17. .a { grid-column: 1 / 3; grid-row: 1; } .b { grid-column: 3; grid-row: 1 / 3; } .c { grid-column: 1; grid-row: 2 / 4; } .a { } .b { } .c { } .container { display: grid; grid-gap: 10px; grid-template-columns: repeat(3, 100px); } Grid Overlap .a { grid-column: 1; grid-row: 1; } .b { grid-column: 2; grid-row: 1; } .c { grid-column: 3; grid-row: 1; }
  • 18. Bootstrap 4 - FlexBootstrap 3 - Float <div class="container"> <div class="row"> <div class="col-xs-4">A</div> <div class="col-xs-4">B</div> <div class="col-xs-4">C</div> </div> </div> Grid <div class="container"> <div class="row"> <div class="col">A</div> <div class="col">B</div> <div class="col">C</div> </div> </div> <div class="container"> <div class="col">A</div> <div class="col">B</div> <div class="col">C</div> </div> .container { display: grid; grid-template-columns: repeat(12, 1fr); grid-gap: 10px; } .col { grid-column: span 4; } .row { display: flex; } .col { flex-basis: 0; flex-grow: 1; }
  • 21. .header { grid-area: H; } .panels.A { grid-area: A; } .panels.B { grid-area: B; } .content { grid-area: C; } .footer { grid-area: F; } <body> <div class="header">H</div> <div class="content">C</div> <div class="panels A">A</div> <div class="panels B">B</div> <div class="footer">F</div> </body> Grid Areas - Easy Prototyping body { display: grid; grid-template-columns: repeat(12, 1fr); grid-template-rows: 1fr 4fr 1fr; grid-template-areas: "H H H H H H H H H H H H" "A C C C C C C C C C C B" "F F F F F F F F F F F F"; }
  • 23. Display: contents <body> <div class="header">H</div> <div class="content">C</div> <div class="panels A">A</div> <div class="panels B">B</div> <div class="footer">F</div> </body> <body> <div class="header">H</div> <div class="container"> <div class="container"> <div class="content">C</div> <div class="panels A">A</div> </div> <div class="panels B">B</div> </div> <div class="footer">F</div> </body> .container { display: contents; }
  • 24. Can I use? display: contents 82.38% JUN 2019 ul, ol { list-style: none; display: contents; } WD .
  • 25. .download-option { display: grid; grid-template-rows: subgrid; grid-row: 1 / -1; } <div class="download-options"> <div class="download-option"> <div>...</div> <h3>...</h3> <ul><li>...</li></ul> <p>...</p> <div><a>...</a><a>...</a></div> </div> ... SubGrid - Cards Alignment .download-options { display: grid; grid-template-rows: repeat(5, auto); }
  • 26. Can I use? Subgrid 0.0% JUN 2019 .items { display: grid; grid-template-columns: subgrid; grid-auto-rows: minmax(100px, auto); } WD .
  • 29. References ● A Complete Guide to Flexbox ● A Complete Guide to Grid ● MDN: CSS layout ● MDN: Subgrid ● Grid by Example ● The Experimental Layouts Lab ● [Games] Grid Garden + Flexbox Froggy ● [Video] Flexbox vs. CSS Grid — Which is Better? ● [Video] Hello Subgrid! ● [Video] CSS Grid: Moving From CSS Frameworks To CSS Grid (2018 and beyond) ● CSS Grids — How Everyone Has Been Building The Web Wrong Before 2018