Hackernoon logoThe Ultimate CSS Grid Cheat Sheet in 2021🎖️ by@joyshaheb

The Ultimate CSS Grid Cheat Sheet in 2021🎖️

image
Joy Shaheb Hacker Noon profile picture

@joyshahebJoy Shaheb

Front end Developer 🔥 || Youtuber 🎬|| Blogger ✍|| K-pop fan ❤️️based in Dhaka, Bangladesh.

Let's refresh Our CSS Grid Memory. Here's a Cheat Sheet of everything you can do with Grid to get started in 2021!🎖️

Check Out The YouTube Tutorial Here

Grid Architecture

image

grid-template-columns

This is used to define the Number & Width of columns. You can either individually set the width of each column, or set a uniform width for all columns using "repeat()" function.

image
image

grid-template-rows

This is used to define the Number & Height of rows. You can either individually set the height of each row, or set a uniform height for all rows using "repeat()" function.

image
image

grid-template-areas

This is used to specify the amount of space a grid cell should carry in terms of column & row across the parent container. Life's quite easier with this as it allows us to see visually what we're doing.

image


Call it, the blueprint(template) of our layout👇

image


column-gap

This property is used to place gap between Columns inside the grid 👇

image


row-gap

This property is used to place gap between Rows inside the grid 👇

image


justify-items

This is used to position grid-items (children) inside the grid container along the X-Axis[Main Axis]. The 4 values are 👇

image
image

align-items

This is used to position grid-items (children) inside grid container along the Y-Axis[Cross Axis]. The 4 values are 👇

image


justify-content

This is used to position our grid [Basically everything] inside grid container along the X-Axis[Main Axis]. The 7 values are 👇

image
image


align-content

This is used to position our grid [Basically everything] inside the grid container along the Y-Axis[Cross Axis]. The 7 values are 👇

image
image

Children Properties

image

The Grid Scale

image
image

grid-column : start/end

THESE 2 properties are used to join multiple COLUMNS together. It is a shorthand of grid-column-start & grid-column-end Skip to this topic on the video above if you're confused using the timestamps.

grid-row : start/end

THESE 2 properties are used to join multiple ROWS together. It is a shorthand of grid-row-start & grid-row-end

grid-area

At first, we need to setup grid-template-areas ☝️ Once done, we have to specify the names used in parent class inside the children classes, like this👇

image


Specifying grid-template-areas inside parent container 👇

image

Specifying the names used in parent container inside children classes with grid-areas👇

image


Justify-self

This is used to position 1 individual grid-item (children) inside grid container along the X-Axis[Main Axis]. The 4 values are 👇

image


align-self

This is used to position 1 individual grid-item (children) inside grid container along the Y-Axis[Cross Axis]. The 4 values are 👇

image

Short Hands

image


place-content

image


place-items

image


place-self

image


grid-template

image


gap/grid-gap

image


Article Credits

image


Conclusion

Here's Your Medal For reading till the end ❤️

Suggestions & Criticisms Are Highly Appreciated ❤️

image

Be sure to check out my other channels and profiles:

  1. YouTube/ Joy Shaheb
  2. Twitter / JoyShaheb
  3. Instagram / JoyShaheb
Joy Shaheb Hacker Noon profile picture
by Joy Shaheb @joyshaheb. Front end Developer 🔥 || Youtuber 🎬|| Blogger ✍|| K-pop fan ❤️️based in Dhaka, Bangladesh.Read my stories

Tags

Join Hacker Noon

Create your free account to unlock your custom reading experience.