A complete beginner's guide to CSS Grid layout ๐Ÿ‘‡๐Ÿป

Thread๐Ÿงต

Grid is used for making complex web design layouts more easily as it's not so hard to master

Using Flex you can make only 1D layout but Grid gives you full power of creating 2D layout

Let's start

{ 2 / 21 }
First things first, start with giving the display property "grid" to the container element or parent element

{ 3 / 21 }
Nothing will change after adding display: flex; in the parent container becuase we need to define the width of columns. In order to set that columns width we have gird-template-columns property

{ 4 / 21 }
Let's start with defining the width of our columns.

For example, let's say I need two columns of width 60% and 40% respectively

grid-template-columns: 60% 40%;

{ 5 / 21 }
Ahh!! My grid items looks ugly as there is no spacing between them.
Here "grid-gap" property comes into play. For example I need 10px spacing along column and row

grid-gap: 10px;

{ 6 / 21 }
Similary we have grid-template-rows.

It is used to define the number of rows and height of rows.

grid-template-rows: 200px 400px;

{ 7 / 21 }
As you can see there is a lot of repeated code in
grid-template-columns: 200px 200px 200px 200px 200px;

Instead of this we can use repeat function ๐Ÿ‘‡๐Ÿป

grid-template-columns: repeat(5, 200px);

{ 8 / 21 }
You might run into some responsiveness issues if you pass pixel unit or percentage in your grid-template-columns

In order to prevent this, it is recommended to use fraction values

For example ๐Ÿ‘‡๐Ÿป

{ 9 / 21 }
You can use repeat function for fr as well

repeat(2, 1fr 2fr);

It wil repeat 1fr 2fr two times.

{ 10 / 21 }
Alright moving forward, you can set he height of grid element using grid-auto-rows

For ex, grid-auto-rows: 200px;

{ 11 / 21 }
Though there is a problem. By doing this, we are setting the fixed height so content inside items can be overflow.

For example ๐Ÿ‘‡๐Ÿป

{ 12 / 21 }
In order to prevent this kind of issues we have minmax function

grid-auto-rows: minmax(200px, auto);

It's pretty intuitive that the height of gird items will be 200px minimun and "auto" maximun(according to content)

{ 13 / 21 }
From 14 to 21

https://t.co/QcX5188vjp

More from Pratham ๐Ÿ‘จโ€๐Ÿ’ป๐Ÿš€

5 amazing GitHub repositories for every self taught developer

A Thread ๐Ÿงต

1๏ธโƒฃ Computer Science

๐ŸŽ“ Path to a free self-taught education in Computer Science!

๐Ÿ”—
https://t.co/67jB5zqIes


2๏ธโƒฃ Free Certifications

Curated list of free courses & certifications

๐Ÿ”— https://t.co/4XtlAVlovs


3๏ธโƒฃ Free Programming Books

๐Ÿ“š Freely available programming books

๐Ÿ”— https://t.co/eOWLCtwtIV


4๏ธโƒฃ JavaScript Question

A long list of (advanced) JavaScript questions, and their explanations โœจ

๐Ÿ”— https://t.co/UvEl1Esvh3
5 great background websites for every web developer and designer

๐Ÿงต๐Ÿ‘‡


1. Magic pattern

Beautiful pure CSS background patterns that you can actually use in your projects. They are highly customizable as well.

๐Ÿ–‡๏ธ
https://t.co/ZqczrPfkdZ


2. Cool backgrounds

Collection of cool backgrounds that you can add to blogs, websites, or as desktop and phone wallpapers

๐Ÿ–‡๏ธ https://t.co/df7VSb9t8H


3. Gradienta

Use pure CSS gradient backgrounds for your next website or app, as a JPG image or CSS code, no attribute required

๐Ÿ–‡๏ธ https://t.co/R58zrwpZCH


4 Mesh gradient

Creat aurora UI like gradients using few simple clicks

๐Ÿ–‡๏ธ https://t.co/vOHHDASr1V
Five free VS Code extensions that will change the way you do web development:

1. RapidAPI Client

Fulfill all your need for API development.

โ€ข Test and consume APIs
โ€ข Work with your VS Code theme
โ€ข Generate TypeScript, Swift, and Python interfaces from responses.

๐Ÿ”—
https://t.co/FR0QhyTi8v


2. Better Comments

Create more human-friendly comments in your code.

โ€ข Alerts
โ€ข Queries
โ€ข TODOs
โ€ข Highlights

๐Ÿ”— https://t.co/AV2BwAMAlL


3. Git Graph

View a Git Graph of your repository and efficiently perform Git actions from the graph.

๐Ÿ”— https://t.co/S5wagmTgsa


4. Peacock

Do you have a habit of keeping multiple VS Code windows open?

Peacock lets you change the color of your VS code even if multiple instances are open.

๐Ÿ”— https://t.co/bmidPkTQOK
12 websites that will help you learn web development faster (completely free): ๐Ÿงต

1. How HTTP Works

Everything you need to know about HTTP based system.

๐Ÿ”—
https://t.co/gVZS4RzS1a


2. 30 Days of Node

Learn Node step by step with interactive examples and code snippet in 30 days.

๐Ÿ”— https://t.co/9nbtMiNB1C


3. How DNS Works

Learn what happens when you type a website address in your browser

๐Ÿ”— https://t.co/SqMRNnDbc3


4. Git

Check out this excellent free website to learn git visually.

๐Ÿ”— https://t.co/rQJMISBDfS

More from Coding

6 amazing GitHub repositories that can help you as a developer

๐Ÿงต ๐Ÿ‘‡๐Ÿป

1๏ธโƒฃ HTML Best Practice

- This repo will help you writing maintainable and scalable HTML documents

๐Ÿ”—
https://t.co/CvvfjSrfCL


2๏ธโƒฃ 30 Days Of React

- Learn React in 30 days. A well divided topics of React in days. Definitely check it out

๐Ÿ”— https://t.co/8WTc1RQOGV


3๏ธโƒฃ Design resources

- Curated list of design and UI resources from stock photos, web templates, CSS frameworks, UI libraries, tools and much more

๐Ÿ”— https://t.co/82o5Eyhlji


4๏ธโƒฃ Websites a programmer should visit

- A well curated list of websites a programmer should visit

๐Ÿ”— https://t.co/ltdIqcQ6cT

You May Also Like