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
If you know CSS then you can use these amazing generators and save your time

Thread 🧵👇🏻

1️⃣ CSS Box Shadow Generator

- Generate CSS3 Box Shadow code for your Div, Frame, Buttons or any other HTML element with Outline, and Inset (inner) type shadow effects

🔗
https://t.co/6La36IzBLj


2️⃣ Glassmorphism

- Generate glassmorphic design easily

🔗 https://t.co/qrKqDV5tzY


3️⃣ Cool Backgrounds

- Explore a beautifully curated selection of cool backgrounds that you can add to your next project

🔗 https://t.co/df7VSaRSh9


4️⃣ Pixel art

- Create CSS pixel art, export the results to CSS and download them.

🔗 https://t.co/ojD8qwzuhx
Use these 6 AI websites to finish hours of work in minutes (take a look):

1. Sheet+

Become a spreadsheet master with Sheet+ AI-powered tools.

• Convert text to formula
• Convert formula to explanation
• Debug formulas
• Generate VBA code
• Get instant answers to any spreadsheet question

🔗
https://t.co/fWsAeKa6ko


2. DeepCode

DeepCode's AI-based code review notifies you about critical bugs in real time and shows you how to fix them.

🔗 https://t.co/dPTPq9syoy


3. Akkio

Grow your business with data-driven decisions.

Go from data to AI in 10 minutes — no code or data science skills required.

🔗 https://t.co/I29FIHDIs0


4. Autocode

Instant endpoints for webhooks, bots, and APIs.

Build and host Node.js endpoints in seconds.

Connect to your favorite APIs like Airtable, Discord, Notion, Slack, Webflow, and more.

🔗 https://t.co/uQZB0NCHJT
Top 5 free APIs for web developers

🧵👇

1️⃣ Custom Search API

- Create your own custom search engine. You can search for image, videos, and news.

🔗
https://t.co/nTvv3c3W06


2️⃣ Movie Database API

- Access movie and TV information similar to that of IMDB.

🔗

3️⃣ Dad Jokes API

- Get random endless dad jokes

🔗

4️⃣ COVID-19 Data API

- Every 15 minutes updated statistic about Coronavirus. Latest stats by country, are collected from several reliable sources.

🔗

More from Coding

These 5 visualizers will help you learn data structures and algorithms up to 10 times faster

Thread 🧵👇🏻

1⃣
https://t.co/H2sKWKEeaz

- Learn DSA and visualize some complex programs. Definitely check it out.


2️⃣ https://t.co/0WcFTWBfh9

- Dedicated to graph DS


3️⃣ https://t.co/ShEQQkjtWD

- Visualizing data structures and algorithms through animation


4️⃣ https://t.co/XxzwBa3vvZ

- All sorting algorithms animations

You May Also Like