Grid Flashcards
How do you create a grid?
Within the selector for the grid container, set the display property to grid and set the amount of columns, rows or both.
How would you create a grid with 2 columns and 2 rows? What about one with 2 columns, or just 2 rows?
grid-template: repeat(2, 1fr) / repeat(2, 100px);
grid-template-rows: repeat(2, 1fr);
grid-template-columns: repeat(2, 1fr);
How do you create a grid where you define where each grid item is placed on the grid or ‘area’?
grid-template-areas: ‘nav’
‘main’
‘footer’;
How could you add spacing between the grid columns and rows?
grid-gap: 10px
For a specific grid item how could you define what column and row it starts and ends at? How about just columns and row?
grid-area: 1 / 1 / 5 / 2;
grid-row: 1 / 5;
grid-column: 1 / 2;
How could you make your grid responsive to change the layout of the grid items when the users screen is smaller? Such as mobile users.
@media only screen and (max-width: 600px) {
grid-template: 200px / repeat(6, 1fr);
}