SlideShare a Scribd company logo
CSS GRID LAYOUT
A S H O R T I N T R O D U C T I O N – PA R T 1
WHAT IS IT?
• CSS Grid Layout introduces a two-dimensional grid system to CSS. Grids can be used
to layout major page areas or small user interface elements.
• A grid is an intersecting set of horizontal and vertical lines – one set defining columns
and the other rows. Elements can be placed onto the grid, respecting these column
and row lines.
• CSS Grid can handle both columns and rows, unlike flexbox which is largely a 1-
dimensional system.
FEATURES
• You can create a grid with fixed columns and rows sizes – using pixels or flexible sizes
with percentages or with the new fr unit designed for this purpose.
• You can place items into a precise location on the grid using line numbers, names or
by targeting an area of the grid. Grid also contains an algorithm to control the
placement of items not given an explicit position on the grid.
• Grid contains alignment features so that we can control how the items align once
placed into a grid area, and how the entire grid is aligned.
A BIT OF HISTORY
• CSS has always been used to lay out our web pages, but it's never done a very good
job of it.
• First, we used tables, then floats, positioning and inline-block, but all of these methods
were essentially hacks and left out a lot of important functionality (vertical centering,
for instance).
• Flexbox helped out, but it's intended for simpler one-dimensional layouts, not complex
two-dimensional ones (Flexbox and Grid actually work very well together).
• Grid is the very first CSS module created specifically to solve the layout problems we've
all been hacking our way around for as long as we've been making websites.
• The beginnings of CSS Grid date back to 2011 and a proposal sent to the CSS Working
Group from Microsoft.
• On October 2017, Microsoft’s Edge browser shipped its implementation of CSS Grid. It
means that all major browsers now support this layout tool. All major browsers rolled
out their implementations in a single year.
BROWSER SUPPORT
* Partial support in IE10 & IE11 with prefix -ms-. It's an old implementation with an
outdated syntax.
TERMINOLOGY
• Grid Container
• Grid Item
• Grid Tracks
• Grid Cell
• Grid Area
• Grid Line
• Gutters
• Fraction Unit
• Implicit/Explicit Grid
GRID CONTAINER
• The element on which display: grid is applied. It's the direct parent of all the grid
items. In this example container is the grid container.
GRID ITEM
• The children (e.g. direct descendants) of the grid container. Here the item elements are
grid items, but sub-item isn't.
GRID TRACKS
• We define rows and columns on with the grid-template-columns and grid-template-
rows properties. These define grid tracks. A grid track is the space between any two
lines on the grid.
GRID CELL
• The space between two adjacent row and two adjacent column grid lines. It's a single
"unit" of the grid.
GRID AREA
• The total space surrounded by four grid lines. A grid area may be comprised of any
number of grid cells. Items can span one or more cells both by row or by column.
• Grid areas must be rectangular – it isn’t possible to create an L-shaped area for
example.
GRID LINE
• The dividing lines that make up the structure of the grid. They can be either vertical
("column grid lines") or horizontal ("row grid lines") and reside on either side of a row
or column.
1
2
3
4
1 2 3 4
1
2
3
4
1 2 3 4
2nd Row
Line
3rd Column
Line
GUTTERS
• Gutters between grid cells can be created using the column-gap and row-gap properties,
or the shorthand gap which takes row-gap and column-gap
• They only appear between tracks of the implicit grid; there is no gutter before the first
track or after the last track.
REPEAT FUNCTION
• Large grids with many tracks can use the repeat() notation, to repeat all or a section of the
track listing.
grid-template-columns: 100px 100px 100px;
===
grid-template-columns: repeat(3, 100px);
grid-template-columns: 100px 200px 100px 200px;
===
grid-template-columns: repeat(2, 100px 200px);
FRACTION UNIT
• Tracks can be defined using any length unit (pixels, percentages, em etc…)
• The fr unit allows you to set the size of a track as a fraction of the free space of the
grid container.
IMPLICIT AND EXPLICIT GRID
• We defined our column tracks with the grid-template-columns property, but the grid
also created rows on its own. These rows are part of the implicit grid.
• Whereas the explicit grid consists of any rows and columns defined with grid-
template-columns or grid-template-rows.
GRID ALIGNMENT
• 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
• In this case you can set the alignment of the grid within the grid container.
• justify-content aligns the grid along the inline (row) axis
• align-content aligns the grid along the block (column) axis
JUSTIFY-CONTENT
start end center stretch
space-around space-between space-evenly
ALIGN-CONTENT
start end center stretch
space-around space-between space-evenly
MINMAX
• Defines a size range for tracks
• Takes two parameters, min and max
• They can be pixels, percentages, fr, max-content and min-content
• max-content – doesn‘t break the content
• min-content – breaks the content
WHAT’S NEXT?
• Grid areas
• Aligning grid items in a grid
• Aligning grid items inside cells
• How to control implicit grid tracks
• How to control auto-placement algorithm
• Animating grid properties
• How to deal with IE
RESOURCES
• CSS Grid Layout Module Level 1 Editor’s Draft
• The Story of CSS Grid, from Its Creators
• Microsoft’s initial proposal of the grid
• Basic concepts of grid layout
• A Complete Guide to Grid
• CSS Grid Layout Support
• How the minmax function works

More Related Content

PDF
World of CSS Grid
PDF
PPTX
Introducing CSS Grid
PDF
CSS Grid Layout Introduction
PDF
CSS Grid Layout. Implementation status and roadmap (Webkit Contributors Meeti...
PDF
Grids of Tomorrow: CSS Grid Layout
PDF
CSS Grid Layout
PDF
CSS Day: CSS Grid Layout
World of CSS Grid
Introducing CSS Grid
CSS Grid Layout Introduction
CSS Grid Layout. Implementation status and roadmap (Webkit Contributors Meeti...
Grids of Tomorrow: CSS Grid Layout
CSS Grid Layout
CSS Day: CSS Grid Layout

What's hot (20)

PDF
The New CSS Layout - dotCSS
PDF
Introduction to CSS Grid Layout
PDF
Future Layout & Performance
PDF
An Event Apart Nashville: CSS Grid Layout
PDF
CSS Grid Layout: An Event Apart Boston 2016
PDF
Flexbox and Grid Layout
PDF
Introducing CSS Grid Layout
PDF
Render Conf: Start using CSS Grid Layout Today
PDF
Grid and Flexbox - Smashing Conf SF
PDF
Frontend United: Start using CSS Grid Layout today!
PDF
Devoxx Belgium: CSS Grid Layout
PDF
The New CSS Layout - Dutch PHP Conference
PDF
An Event Apart SF: CSS Grid Layout
PDF
Fluent: Making Sense of the New CSS Layout
PDF
But what about old browsers?
PDF
CSS Grid Layout - All Things Open
PDF
Talk Web Design: Get Ready For CSS Grid Layout
PDF
CSS Conf Budapest - New CSS Layout
PDF
What I discovered about layout vis CSS Grid
PDF
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
The New CSS Layout - dotCSS
Introduction to CSS Grid Layout
Future Layout & Performance
An Event Apart Nashville: CSS Grid Layout
CSS Grid Layout: An Event Apart Boston 2016
Flexbox and Grid Layout
Introducing CSS Grid Layout
Render Conf: Start using CSS Grid Layout Today
Grid and Flexbox - Smashing Conf SF
Frontend United: Start using CSS Grid Layout today!
Devoxx Belgium: CSS Grid Layout
The New CSS Layout - Dutch PHP Conference
An Event Apart SF: CSS Grid Layout
Fluent: Making Sense of the New CSS Layout
But what about old browsers?
CSS Grid Layout - All Things Open
Talk Web Design: Get Ready For CSS Grid Layout
CSS Conf Budapest - New CSS Layout
What I discovered about layout vis CSS Grid
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
Ad

Similar to Css Grid Layout - A Short Introduction - Part 1 (20)

PDF
Flexbox, Grid and Sass
PDF
The Grid - The Future of CSS Layout
PPTX
MTA css layouts
PDF
CSS Grid Layout for Topconf, Linz
PPTX
Vector data model
PPTX
Vector data model
PDF
JavaFX Layout Secrets with Amy Fowler
PDF
Grid system introduction
PPTX
Bootstrap SLIDES for web development course
PPTX
Bootstrap ppt
PDF
CSS Grid Layout
PPTX
What is grid system
PPTX
PPTX
introduction of Data strutter and algirithm.pptx
PPT
17523630.ppt
PDF
Ppt ch06
PDF
Ppt ch06
PDF
Laying out the future with grid & flexbox - Smashing Conf Freiburg
PPTX
Applied GIS - 3022.pptx
PPTX
Using Bootstrap to Make Accessible Front-Ends(2).pptx
Flexbox, Grid and Sass
The Grid - The Future of CSS Layout
MTA css layouts
CSS Grid Layout for Topconf, Linz
Vector data model
Vector data model
JavaFX Layout Secrets with Amy Fowler
Grid system introduction
Bootstrap SLIDES for web development course
Bootstrap ppt
CSS Grid Layout
What is grid system
introduction of Data strutter and algirithm.pptx
17523630.ppt
Ppt ch06
Ppt ch06
Laying out the future with grid & flexbox - Smashing Conf Freiburg
Applied GIS - 3022.pptx
Using Bootstrap to Make Accessible Front-Ends(2).pptx
Ad

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Empathic Computing: Creating Shared Understanding
PPT
Teaching material agriculture food technology
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Cloud computing and distributed systems.
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
DOCX
The AUB Centre for AI in Media Proposal.docx
Machine learning based COVID-19 study performance prediction
The Rise and Fall of 3GPP – Time for a Sabbatical?
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
NewMind AI Weekly Chronicles - August'25 Week I
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
NewMind AI Monthly Chronicles - July 2025
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Mobile App Security Testing_ A Comprehensive Guide.pdf
Empathic Computing: Creating Shared Understanding
Teaching material agriculture food technology
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Cloud computing and distributed systems.
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Encapsulation_ Review paper, used for researhc scholars
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
The AUB Centre for AI in Media Proposal.docx

Css Grid Layout - A Short Introduction - Part 1

  • 1. CSS GRID LAYOUT A S H O R T I N T R O D U C T I O N – PA R T 1
  • 2. WHAT IS IT? • CSS Grid Layout introduces a two-dimensional grid system to CSS. Grids can be used to layout major page areas or small user interface elements. • A grid is an intersecting set of horizontal and vertical lines – one set defining columns and the other rows. Elements can be placed onto the grid, respecting these column and row lines. • CSS Grid can handle both columns and rows, unlike flexbox which is largely a 1- dimensional system.
  • 3. FEATURES • You can create a grid with fixed columns and rows sizes – using pixels or flexible sizes with percentages or with the new fr unit designed for this purpose. • You can place items into a precise location on the grid using line numbers, names or by targeting an area of the grid. Grid also contains an algorithm to control the placement of items not given an explicit position on the grid. • Grid contains alignment features so that we can control how the items align once placed into a grid area, and how the entire grid is aligned.
  • 4. A BIT OF HISTORY • CSS has always been used to lay out our web pages, but it's never done a very good job of it. • First, we used tables, then floats, positioning and inline-block, but all of these methods were essentially hacks and left out a lot of important functionality (vertical centering, for instance). • Flexbox helped out, but it's intended for simpler one-dimensional layouts, not complex two-dimensional ones (Flexbox and Grid actually work very well together). • Grid is the very first CSS module created specifically to solve the layout problems we've all been hacking our way around for as long as we've been making websites. • The beginnings of CSS Grid date back to 2011 and a proposal sent to the CSS Working Group from Microsoft. • On October 2017, Microsoft’s Edge browser shipped its implementation of CSS Grid. It means that all major browsers now support this layout tool. All major browsers rolled out their implementations in a single year.
  • 5. BROWSER SUPPORT * Partial support in IE10 & IE11 with prefix -ms-. It's an old implementation with an outdated syntax.
  • 6. TERMINOLOGY • Grid Container • Grid Item • Grid Tracks • Grid Cell • Grid Area • Grid Line • Gutters • Fraction Unit • Implicit/Explicit Grid
  • 7. GRID CONTAINER • The element on which display: grid is applied. It's the direct parent of all the grid items. In this example container is the grid container.
  • 8. GRID ITEM • The children (e.g. direct descendants) of the grid container. Here the item elements are grid items, but sub-item isn't.
  • 9. GRID TRACKS • We define rows and columns on with the grid-template-columns and grid-template- rows properties. These define grid tracks. A grid track is the space between any two lines on the grid.
  • 10. GRID CELL • The space between two adjacent row and two adjacent column grid lines. It's a single "unit" of the grid.
  • 11. GRID AREA • The total space surrounded by four grid lines. A grid area may be comprised of any number of grid cells. Items can span one or more cells both by row or by column. • Grid areas must be rectangular – it isn’t possible to create an L-shaped area for example.
  • 12. GRID LINE • The dividing lines that make up the structure of the grid. They can be either vertical ("column grid lines") or horizontal ("row grid lines") and reside on either side of a row or column. 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 2nd Row Line 3rd Column Line
  • 13. GUTTERS • Gutters between grid cells can be created using the column-gap and row-gap properties, or the shorthand gap which takes row-gap and column-gap • They only appear between tracks of the implicit grid; there is no gutter before the first track or after the last track.
  • 14. REPEAT FUNCTION • Large grids with many tracks can use the repeat() notation, to repeat all or a section of the track listing. grid-template-columns: 100px 100px 100px; === grid-template-columns: repeat(3, 100px); grid-template-columns: 100px 200px 100px 200px; === grid-template-columns: repeat(2, 100px 200px);
  • 15. FRACTION UNIT • Tracks can be defined using any length unit (pixels, percentages, em etc…) • The fr unit allows you to set the size of a track as a fraction of the free space of the grid container.
  • 16. IMPLICIT AND EXPLICIT GRID • We defined our column tracks with the grid-template-columns property, but the grid also created rows on its own. These rows are part of the implicit grid. • Whereas the explicit grid consists of any rows and columns defined with grid- template-columns or grid-template-rows.
  • 17. GRID ALIGNMENT • 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 • In this case you can set the alignment of the grid within the grid container. • justify-content aligns the grid along the inline (row) axis • align-content aligns the grid along the block (column) axis
  • 18. JUSTIFY-CONTENT start end center stretch space-around space-between space-evenly
  • 19. ALIGN-CONTENT start end center stretch space-around space-between space-evenly
  • 20. MINMAX • Defines a size range for tracks • Takes two parameters, min and max • They can be pixels, percentages, fr, max-content and min-content • max-content – doesn‘t break the content • min-content – breaks the content
  • 21. WHAT’S NEXT? • Grid areas • Aligning grid items in a grid • Aligning grid items inside cells • How to control implicit grid tracks • How to control auto-placement algorithm • Animating grid properties • How to deal with IE
  • 22. RESOURCES • CSS Grid Layout Module Level 1 Editor’s Draft • The Story of CSS Grid, from Its Creators • Microsoft’s initial proposal of the grid • Basic concepts of grid layout • A Complete Guide to Grid • CSS Grid Layout Support • How the minmax function works