Css Grid for begginers

Everything you wanted to know about grid.
This is all about grid. Nothing else.

Css Grid - setting collumns only.

1

When you set a css grid, and define columns only, not rows, the browser will spread the elements according to your settings. All elements inside the block will be arranged one by one to the end of the grid. If you have set 4 columns to your grid but have 8 elements, the browser will place the first 4 in the fisrt row and the other four in the second row automatically.
Like in this grid, we have set 3 columns but we have 6 elements in the block. "display: grid="1fr 3fr 1fr" The rows are filled as the elements are placed in the block. Read section 2 to find out about the gap and why we have 3 rows and not two, and why there is a blank space at the bottom of the grid.

2

OK.
Now, look the way we set the grid: 1fr 3fr 1fr. What does this mean? It simply means that the second column is 3 times the size of the others. Thats why, you see the second column larger than the others. Have you noticed?
The other thing that is important to know about this grid, is that I have set the third column to be expanded up to 3 rows if necessary.
This is how you do it: First you have to name the element you want to expand. In this case the third one. On your stylesheet you write #'Id_name' { grid-row: span 3; }
I wanted the third column to expand 3 rows, so I set it to 3. Thats why you see the darker column expanding 3 rows.
The problem with the grid is that all the rows will have the same height, and they will be set automatically to the larger one. In this example, the first column is larger, so the second column is not completely filling the whole space reserved for it.

3

THIS IS THE THIRD COLUMN.

This is the row I've chosen to expand 3 rows. Doesn't matter what content I have inside. The browser will set it to three. As stated in the second paragraph, 'span' is the keyword responsible for expanding the column. In my example I gave span the value of 3. See the sintax above.
Don't worry about the format, I have changed the colors so that it can stand out among the others.

4

This is the fourth child of the container, or simply the fourth element.
do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

5

This is the fifth child of the container, or simply the fifth element.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

6

This is the sixth child of the container, or simply the sixth element.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Using Grid-Template-Areas format

Grid-Template-Areas is used to create grids with different sizes of spaces. The way you do that is giving names to the cells

Header
Menu
Main
Right
Footer

'header header header header header header' -->Name the cells you want to be a container. Here header has 6 columns and 1 row and set the items in the css file*/
'menu main main main right right' --> In here, menu has 1 column and 2 rows. Main has 3 columns and right has 2.
'menu footer footer footer footer footer' --> footer has 5 columns

display: inline-grid

display inline-grid makes a grid with the size of the content

1
2
3
4
5
6
7
8
9

display: grid

display grid makes a grid with the size of the media

1
2
3
4
5
6
7
8
9
A Tag 'legend' da o titulo à caixa

a tag 'fieldset' cria a caixa

Fieldset and label Tags using grid

You can use grid to display a form with inputs with the same size

Form made with display: grid

Hello Ricardo

Just another grid template with a full length in case you want to build a site with different styles.

A criminally cute dog. lol

This text is placed on top of the image on purpose, so that you can see how far you can go with CSS

This is another example of grid made with grid-area

You can give any format you want to your grids, when using grid areas. It's good for websites with lots of text and information

Lorem ipsum dolor sit amet consectetur adipiscing elit. Exercitationem eos ad valorem. Lorem ipsum dolor sit amet consectetur adipiscing elit

Lorem ipsum dolor sit amet consectetur adipiscing elit. Exercitationem eos ad valorem. Lorem ipsum dolor sit amet consectetur adipiscing elit

Lorem ipsum dolor sit amet consectetur adipiscing elit. Exercitationem eos ad valorem. Lorem ipsum dolor sit amet consectetur adipiscing elit

Lorem ipsum dolor sit amet consectetur adipiscing elit. Exercitationem eos ad valorem. Lorem ipsum dolor sit amet consectetur adipiscing elit

Lorem ipsum dolor sit amet consectetur adipiscing elit. Exercitationem eos ad valorem. Lorem ipsum dolor sit amet consectetur adipiscing elit

Lorem ipsum dolor sit amet consectetur adipiscing elit. Exercitationem eos ad valorem. Lorem ipsum dolor sit amet consectetur adipiscing elit

Lorem ipsum dolor sit amet consectetur adipiscing elit. Exercitationem eos ad valorem. Lorem ipsum dolor sit amet consectetur adipiscing elit