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
7 amazing websites that will help you improve your CSS skills

🧵👇

1️⃣ Learn to code HTML and CSS

- Learn how to build beautiful and intuitive websites by way of clear and organized lessons

🖇️
https://t.co/bl2rx2q8vk


2️⃣ CSS reference

- CSS Reference is a free visual guide to CSS. It features the most popular properties, and explains them with illustrated and animated content

🖇️ https://t.co/XAlj33g1Zk


3️⃣ CSS tutorial

- These tutorials on web design & CSS makes learning this stuff fun and easy

🖇️ https://t.co/y9vAj6fMGk


4️⃣ CSS Layouts

- This site teaches the CSS fundamentals that are used in any website's layout.

🖇️ https://t.co/n4EGLScpDF
5 great gradient background sites for every web developer and designer 🎨

🧵👇🏻


1️⃣ uiGradients

- A handpicked collection of beautiful color gradients for designers and developers.

🔗
https://t.co/EainhiePop


2️⃣ Eggradient

- Ready to use gradient background colors. ✓ Cool Gradients are prepared according to the latest design trends

🔗 https://t.co/F0uYVsZbA4


3️⃣ Mesh Gradients

- Create beautiful gradient like aurora UI in few clicks

🔗 https://t.co/MV8PT7q3Kz


4️⃣ CSS Gradient

- Create beatiful gradeint either linear or radial on different angles

🔗 https://t.co/dlCExilHAT
7 GitHub repositories will make you a standout developer from 99% of people:

1. Memphis

An open-source real-time data processing platform.

• Message broker
• Schema Management
• Zero ops
• Cloud-native
• Rapid development
• Significantly lower development time

🔗
https://t.co/w5L2aCM3do


2. The art of command line

Master the command line, in one page.

🔗 https://t.co/uF2RlcUIxb


3. Public APIs

A collective list of free APIs for use in software and web development

🔗 https://t.co/vDRQKBf15V


4. Hover

A collection of CSS3 powered hover effects to be applied to links, buttons, logos, SVG, featured images and so on.

🔗 https://t.co/bIGEEPcMkJ

More from Coding

5 amazing websites that will blow the mind of a developer. Definitely check them out

🧵👇🏻

1️⃣ Animation generator

- Dead simple visual tools to help you generate CSS for your projects.

🔗
https://t.co/IFmIEgDiVY


2️⃣ Neural Network Visualizer

- Deep playground is an interactive visualization of neural networks, written in TypeScript using d3.js.

🔗 https://t.co/mTAlFbJsOW


3️⃣ Blockchain Demo

- A visual demo of blockchain technology

🔗 https://t.co/I1RwxYcM1Z


4️⃣ Developer Roadmaps

- Step by step guides and paths to learn different tools or technologies

🔗 https://t.co/VSNPdG8jQR

You May Also Like