Pratham Profile picture
Mar 24, 2021 14 tweets 5 min read Read on X
A complete beginner's guide to CSS Grid layout 👇🏻

Thread🧵 Image
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 } Image
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 } ImageImage
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 } Image
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 } ImageImage
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 } Image
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 } ImageImage
You can use repeat function for fr as well

repeat(2, 1fr 2fr);

It wil repeat 1fr 2fr two times.

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

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

{ 11 / 21 } Image
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 } Image
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 } Image

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Pratham

Pratham Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Prathkum

Apr 30
CORS is the biggest headache for developers.

In the next 3 minutes, you will be able to tackle CORS errors much more effectively.
CORS is not rocket science.

It's the biggest pain for developers because the majority of us don't know its core concept.

Let's try to build a solid fundamental.

Stands for Cross-Origin Resource Sharing.
It is a security feature implemented by web browsers (almost all) that controls how web pages from one domain can request resources hosted on another domain.
Read 9 tweets
Apr 7
APIs are the backbone of development.

Let me show you how to build your first basic REST API in four simple steps.
Step 1: Install Node.js

I'm assuming you have Node.js installed on your machine. If you haven't installed it, click on the following link and install it simply.

nodejs.org/en
Step 2: Initialize the project

Let's start; create an empty directory and initialize your project by running the following command. Image
Read 17 tweets
Apr 4
5 GitHub repositories will make your life 90% easier:
1. StackQL

StackQL allows you to query multiple cloud and SaaS providers (Google, AWS, Azure, Okta, GitHub, etc.) using SQL.

🔗 github.com/stackql/stackql
Image
2. 50 Projects 50 Days

50+ mini web projects using HTML, CSS & JavaScript.

🔗 github.com/bradtraversy/5…
Image
Read 6 tweets
Feb 2
Convert your Python application into a website in 2 minutes.

Let me show you how:
There's no easy way than this to build a data, AI-based web applications.

I came across Taipy.

It is an open-source Python library for building production-ready front-end & back-end in no time.
Let's see in five simple steps how to build a movie recommendation system using Taipy.
Read 11 tweets
Jan 23
6 free Books to learn web development:
1. The Magic of CSS

The content in this eBook is for all-level developers. Learn about layout, box-model, positioning etc. with sample code snippets.

adamschwartz.co/magic-of-css/
Image
2. DOM Enlightenment

"DOM Enlightenment" is a free online book that explores DOM in-depth, providing a clear and detailed understanding of how it works.

domenlightenment.com
Image
Read 7 tweets
Jan 8
5 GitHub repositories that will make your life 90% easier if you write code:
1. Refine

A React Framework for building internal tools, admin panels, dashboards & B2B apps with unmatched flexibility.

Speed up your development timeline.

🔗 github.com/refinedev/refi…
Image
2. Keystone

The most powerful headless CMS for Node.js — built with GraphQL and React

🔗 github.com/keystonejs/key…
Image
Read 6 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(