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 the full power of creating a 2D layout.
Let's start:
Using Flex, you can make only 1D layout but Grid gives you the full power of creating a 2D layout.
Let's start:
Nothing will change after adding display: flex; in the parent container because we need to define the width of columns. In order to set that column's width, we have the `gird-template-columns` property.
Alright moving forward, The next property we have is `grid-template-areas` which specifies the areas within the grid layout.
Each row is defined by apostrophes (' ')
Sounds confusing? Let's see this in action.
Each row is defined by apostrophes (' ')
Sounds confusing? Let's see this in action.
Now let's apply this area (areaName) to the first grid item.
.one {
grid-area: areaName;
}
As you can see item1 takes one entire row and 5 columns. As simple as that
codepen.io
.one {
grid-area: areaName;
}
As you can see item1 takes one entire row and 5 columns. As simple as that
codepen.io
Alright, moving further let's talk about the context of Grid items.
We can set the ordering and alignment of a particular item. Let's dive into it.
We can set the ordering and alignment of a particular item. Let's dive into it.
📌 The Order of the items
The order is nothing but used to set the order of an item within the grid container.
The order is nothing but used to set the order of an item within the grid container.
📌 Alignment in CSS Grid Layout
This is confusing, but we will cover everything in this thread.
justify-content
align-items
justify-self
align-self
This is confusing, but we will cover everything in this thread.
justify-content
align-items
justify-self
align-self
The `justify-content` is used to align the container's items when the items do not use all available space on the `main-axis` (horizontally).
🔗 w3schools.com
🔗 w3schools.com
The `align-items` property specifies the default alignment for items inside the flexible container.
🔗 w3schools.com
🔗 w3schools.com
Try to play around with the code here. This might be a little confusing initially, but once you get used to it, it all becomes pretty easy.
codepen.io
codepen.io
I think that's pretty much it, If you like this thread share it with your connections. 😁
Follow @Prathkum for more!
Follow @Prathkum for more!
Loading suggestions...