CSS Grid Tutorial

In this CSS article we want to talk about CSS Grid Tutorial, CSS Grid is powerful layout tool that allows you to create complex and responsive layouts with easy. in this article we want to talk about the basics of CSS Grid and show you how to create simple grid layout.

 

 

What is CSS Grid ?

CSS Grid is two dimensional layout system that allows you to create complex layouts with easiness. it is made up of a grid container and grid items. grid container is the element that contains grid items and defines the grid. grid items are the elements that are laid out on the grid.

 

 

For creating grid layout you need to define grid container and specify the number of rows and columns in the grid. you can do this using grid template rows and grid template columns properties. for example:

In this example we have created grid container with three rows and three columns using the repeat() function to specify the number of rows and columns. 1fr unit is used to specify that each row and column should take up an equal amount of space.

 

 

After that you have defined the grid container you can add grid items to the grid. for this you need to specify the location of the grid item using the grid row and grid column properties. for example:

In this example we have created seven grid items and specify their location using the grid row and grid column properties. values for these properties are specified using the row-start / row-end and column-start / column-end syntax. for example grid-row: 1 / 2 specifies that the grid item should span from row 1 to row 2.

 

 

Also when you have created your grid layout and added your grid items you can style them as you would any other element. for example:

 

 

One of the great things about CSS Grid is that it makes it easy to create responsive layouts. to make the grid responsive you can use media queries to change the number of columns in the grid based on the screen size. for example:

 

 

 

This is the complete code with HTML

 

 

This will be the result

CSS Grid Tutorial
CSS Grid Tutorial

 

 

 

Learn More on CSS

Leave a Comment