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 👨‍💻🚀

Six tools that will change the way your write code: 🧵

1️⃣ HarperDB

Deciding between SQL and NoSQL? Use HarperDB as it provides you the functionality of both.

Access data using API endpoint.

🔗
https://t.co/qf5CalexfA


2️⃣ Visual Go

Visualizing data structures and algorithms

🔗 https://t.co/b8YeMYdOaf


3️⃣ Extends Class

Syntax validators, code formatter, testers, HTTP clients, mock server, and much more.

🔗 https://t.co/GlKjoBnzqg


4️⃣ Codeshare

Share Code in Real-time with Developers. An online editor for teaching and interviewing.

🔗 https://t.co/2m1Ne3KJRK
9 websites that will help you learn web development faster (they are 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

Do not write CSS code, use these free generators instead that can help you immensely

A Thread 🧵

1️⃣ Stripes generator

- Pure CSS Stripes Generator that you can use for backgrounds.

🔗
https://t.co/5uTPrwA5xD


2️⃣ Gradient generator

- As a free css gradient generator tool, this website lets you create a colorful gradient background for your website, blog, or social media profile

🔗 https://t.co/Yr6pueoWgx


3️⃣ Pattern generator

- It lets you create background pattern for free

🔗 https://t.co/NQuV7pxLIz


4️⃣ CSS Accordion Slider Generator

- Create fully responsive, css only accordion sliders

🔗 https://t.co/x0qaDhN0z9
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

प्राचीन काल में गाधि नामक एक राजा थे।उनकी सत्यवती नाम की एक पुत्री थी।राजा गाधि ने अपनी पुत्री का विवाह महर्षि भृगु के पुत्र से करवा दिया।महर्षि भृगु इस विवाह से बहुत प्रसन्न हुए और उन्होने अपनी पुत्रवधु को आशीर्वाद देकर उसे कोई भी वर मांगने को कहा।


सत्यवती ने महर्षि भृगु से अपने तथा अपनी माता के लिए पुत्र का वरदान मांगा।ये जानकर महर्षि भृगु ने यज्ञ किया और तत्पश्चात सत्यवती और उसकी माता को अलग-अलग प्रकार के दो चरू (यज्ञ के लिए पकाया हुआ अन्न) दिए और कहा कि ऋतु स्नान के बाद तुम्हारी माता पुत्र की इच्छा लेकर पीपल का आलिंगन...

...करें और तुम भी पुत्र की इच्छा लेकर गूलर वृक्ष का आलिंगन करना। आलिंगन करने के बाद चरू का सेवन करना, इससे तुम दोनो को पुत्र प्राप्ति होगी।परंतु मां बेटी के चरू आपस में बदल जाते हैं और ये महर्षि भृगु अपनी दिव्य दृष्टि से देख लेते हैं।

भृगु ऋषि सत्यवती से कहते हैं,"पुत्री तुम्हारा और तुम्हारी माता ने एक दुसरे के चरू खा लिए हैं।इस कारण तुम्हारा पुत्र ब्राह्मण होते हुए भी क्षत्रिय सा आचरण करेगा और तुम्हारी माता का पुत्र क्षत्रिय होकर भी ब्राह्मण सा आचरण करेगा।"
इस पर सत्यवती ने भृगु ऋषि से बड़ी विनती की।


सत्यवती ने कहा,"मुझे आशीर्वाद दें कि मेरा पुत्र ब्राह्मण सा ही आचरण करे।"तब महर्षि ने उसे ये आशीर्वाद दे दिया कि उसका पुत्र ब्राह्मण सा ही आचरण करेगा किन्तु उसका पौत्र क्षत्रियों सा व्यवहार करेगा। सत्यवती का एक पुत्र हुआ जिसका नाम जम्दाग्नि था जो सप्त ऋषियों में से एक हैं।