|  | 
| 1 |  | -# CSS Grid CheatSheet | 
| 2 |  | - | 
| 3 |  | -## ****1. Grid container properties**** | 
| 4 |  | - | 
| 5 |  | -### Display | 
| 6 |  | - | 
| 7 |  | -```css | 
| 8 |  | -/* Sets the element to a grid container. */ | 
| 9 |  | -.container { | 
| 10 |  | -  display: grid; | 
| 11 |  | -} | 
| 12 |  | -``` | 
| 13 |  | - | 
| 14 |  | -### Grid Template Columns | 
| 15 |  | - | 
| 16 |  | -```css | 
| 17 |  | -/* Defines the columns of the grid. */ | 
| 18 |  | -.container { | 
| 19 |  | -  grid-template-columns: 100px 100px 100px; | 
| 20 |  | -} | 
| 21 |  | -``` | 
| 22 |  | - | 
| 23 |  | -### Grid Template Rows | 
| 24 |  | - | 
| 25 |  | -```css | 
| 26 |  | -/* Defines the rows of the grid. */ | 
| 27 |  | -.container { | 
| 28 |  | -  grid-template-rows: 100px 100px; | 
| 29 |  | -} | 
| 30 |  | -``` | 
| 31 |  | - | 
| 32 |  | -### Grid Template Areas | 
| 33 |  | - | 
| 34 |  | -```css | 
| 35 |  | -/* Defines the areas of the grid. */ | 
| 36 |  | -.container { | 
| 37 |  | -  grid-template-areas:  | 
| 38 |  | -    "header header" | 
| 39 |  | -    "sidebar content" | 
| 40 |  | -    "footer footer"; | 
| 41 |  | -} | 
| 42 |  | -``` | 
| 43 |  | - | 
| 44 |  | -### Gap | 
| 45 |  | - | 
| 46 |  | -```css | 
| 47 |  | -/* Specifies the size of the gap between grid items. */ | 
| 48 |  | -.container { | 
| 49 |  | -  gap: 10px; | 
| 50 |  | -} | 
| 51 |  | -``` | 
| 52 |  | - | 
| 53 |  | -### Justify Items | 
| 54 |  | - | 
| 55 |  | -```css | 
| 56 |  | -/* Aligns items along the inline (row) axis. */ | 
| 57 |  | -.container { | 
| 58 |  | -  justify-items: center; | 
| 59 |  | -} | 
| 60 |  | -``` | 
| 61 |  | - | 
| 62 |  | -### Align Items | 
| 63 |  | - | 
| 64 |  | -```css | 
| 65 |  | -/* Aligns items along the block (column) axis. */ | 
| 66 |  | -.container { | 
| 67 |  | -  align-items: center; | 
| 68 |  | -} | 
| 69 |  | -``` | 
| 70 |  | - | 
| 71 |  | -### Justify Content | 
| 72 |  | - | 
| 73 |  | -```css | 
| 74 |  | -/* Aligns the grid along the inline (row) axis. */ | 
| 75 |  | -.container { | 
| 76 |  | -  justify-content: center; | 
| 77 |  | -} | 
| 78 |  | -``` | 
| 79 |  | - | 
| 80 |  | -### Align Content | 
| 81 |  | - | 
| 82 |  | -```css | 
| 83 |  | -/* Aligns the grid along the block (column) axis. */ | 
| 84 |  | -.container { | 
| 85 |  | -  align-content: center; | 
| 86 |  | -} | 
| 87 |  | -``` | 
| 88 |  | - | 
| 89 |  | -## 2. Grid Item Properties | 
| 90 |  | - | 
| 91 |  | -### Grid Column Start | 
| 92 |  | - | 
| 93 |  | -```css | 
| 94 |  | -/* Specifies the start position of a grid item along the inline (row) axis. */ | 
| 95 |  | -.item { | 
| 96 |  | -  grid-column-start: 1; | 
| 97 |  | -} | 
| 98 |  | -``` | 
| 99 |  | - | 
| 100 |  | -### Grid Column End | 
| 101 |  | - | 
| 102 |  | -```css | 
| 103 |  | -/* Specifies the end position of a grid item along the inline (row) axis. */ | 
| 104 |  | -.item { | 
| 105 |  | -  grid-column-end: 3; | 
| 106 |  | -} | 
| 107 |  | -``` | 
| 108 |  | - | 
| 109 |  | -### Grid Row Start | 
| 110 |  | - | 
| 111 |  | -```css | 
| 112 |  | -/* Specifies the start position of a grid item along the block (column) axis. */ | 
| 113 |  | -.item { | 
| 114 |  | -  grid-row-start: 1; | 
| 115 |  | -} | 
| 116 |  | -``` | 
| 117 |  | - | 
| 118 |  | -### Grid Row End | 
| 119 |  | - | 
| 120 |  | -```css | 
| 121 |  | -/* Specifies the end position of a grid item along the block (column) axis. */ | 
| 122 |  | -.item { | 
| 123 |  | -  grid-row-end: 3; | 
| 124 |  | -} | 
| 125 |  | -``` | 
| 126 |  | - | 
| 127 |  | -### Grid Area | 
| 128 |  | - | 
| 129 |  | -```css | 
| 130 |  | -/* Specifies both the start and end positions of a grid item. */ | 
| 131 |  | -.item { | 
| 132 |  | -  grid-area: 1 / 1 / 3 / 3; | 
| 133 |  | -} | 
| 134 |  | -``` | 
| 135 |  | - | 
| 136 |  | -### Justify Self | 
| 137 |  | - | 
| 138 |  | -```css | 
| 139 |  | -/* Aligns a grid item along the inline (row) axis. */ | 
| 140 |  | -.item { | 
| 141 |  | -  justify-self: center; | 
| 142 |  | -} | 
| 143 |  | -``` | 
| 144 |  | - | 
| 145 |  | -### Align Self | 
| 146 |  | -```css | 
| 147 |  | -/* Aligns a grid item along the block (column) axis. */ | 
| 148 |  | -.item { | 
| 149 |  | -  align-self: center; | 
| 150 |  | -} | 
| 151 |  | -``` | 
| 152 |  | - | 
| 153 |  | -Learn More about CSS Grid from here: | 
| 154 |  | -[![Learn CSS Grid in 35 minutes: The Ultimate Crash Course for Beginners]](https://www.youtube.com/embed/ULp7wPJ-rzQ "Learn CSS Grid in 35 minutes: The Ultimate Crash Course for Beginners") | 
|  | 1 | + | 
|  | 2 | + | 
|  | 3 | +# CSS Grid Cheatsheet | 
|  | 4 | +## 1. Grid container properties | 
|  | 5 | + | 
|  | 6 | +## Display | 
|  | 7 | +```css | 
|  | 8 | +/* Sets the element to a grid container. */ | 
|  | 9 | +.container { | 
|  | 10 | +  display: grid; | 
|  | 11 | +} | 
|  | 12 | +``` | 
|  | 13 | + | 
|  | 14 | +## Grid Template Columns | 
|  | 15 | +```css | 
|  | 16 | +/* Defines the columns of the grid. */ | 
|  | 17 | +.container { | 
|  | 18 | +  grid-template-columns: 100px 100px 100px; | 
|  | 19 | +} | 
|  | 20 | +``` | 
|  | 21 | + | 
|  | 22 | +## Grid Template Rows | 
|  | 23 | +```css | 
|  | 24 | +/* Defines the rows of the grid. */ | 
|  | 25 | +.container { | 
|  | 26 | +  grid-template-rows: 100px 100px; | 
|  | 27 | +} | 
|  | 28 | +``` | 
|  | 29 | + | 
|  | 30 | +## Grid Template Areas | 
|  | 31 | +```css | 
|  | 32 | +/* Defines the areas of the grid. */ | 
|  | 33 | +.container { | 
|  | 34 | +  grid-template-areas:  | 
|  | 35 | +    "header header" | 
|  | 36 | +    "sidebar content" | 
|  | 37 | +    "footer footer"; | 
|  | 38 | +} | 
|  | 39 | +``` | 
|  | 40 | + | 
|  | 41 | +## Gap | 
|  | 42 | +```css | 
|  | 43 | +/* Specifies the size of the gap between grid items. */ | 
|  | 44 | +.container { | 
|  | 45 | +  gap: 10px; | 
|  | 46 | +} | 
|  | 47 | +``` | 
|  | 48 | + | 
|  | 49 | +## Justify Items | 
|  | 50 | +```css | 
|  | 51 | +/* Aligns items along the inline (row) axis. */ | 
|  | 52 | +.container { | 
|  | 53 | +  justify-items: center; | 
|  | 54 | +} | 
|  | 55 | +``` | 
|  | 56 | + | 
|  | 57 | +# Align Items | 
|  | 58 | +```css | 
|  | 59 | +/* Aligns items along the block (column) axis. */ | 
|  | 60 | +.container { | 
|  | 61 | +  align-items: center; | 
|  | 62 | +} | 
|  | 63 | +``` | 
|  | 64 | + | 
|  | 65 | +# Justify Content | 
|  | 66 | +```css | 
|  | 67 | +/* Aligns the grid along the inline (row) axis. */ | 
|  | 68 | +.container { | 
|  | 69 | +  justify-content: center; | 
|  | 70 | +} | 
|  | 71 | +``` | 
|  | 72 | + | 
|  | 73 | +# Align Content | 
|  | 74 | +```css | 
|  | 75 | +/* Aligns the grid along the block (column) axis. */ | 
|  | 76 | +.container { | 
|  | 77 | +  align-content: center; | 
|  | 78 | +} | 
|  | 79 | +``` | 
|  | 80 | + | 
|  | 81 | +## 2. Grid Item Properties | 
|  | 82 | +## Grid Column Start | 
|  | 83 | + | 
|  | 84 | +```css | 
|  | 85 | +/* Specifies the start position of a grid item along the inline (row) axis. */ | 
|  | 86 | +.item { | 
|  | 87 | +  grid-column-start: 1; | 
|  | 88 | +} | 
|  | 89 | +``` | 
|  | 90 | + | 
|  | 91 | +## Grid Column End | 
|  | 92 | +```css  | 
|  | 93 | +/* Specifies the start position of a grid item along the inline (row) axis. */ | 
|  | 94 | +.item { | 
|  | 95 | +  grid-column-start: 1; | 
|  | 96 | +} | 
|  | 97 | +``` | 
|  | 98 | + | 
|  | 99 | +## Grid Row Start | 
|  | 100 | +```css | 
|  | 101 | +/* Specifies the start position of a grid item along the block (column) axis. */ | 
|  | 102 | +.item { | 
|  | 103 | +  grid-row-start: 1; | 
|  | 104 | +} | 
|  | 105 | +``` | 
|  | 106 | + | 
|  | 107 | +## Grid Row End | 
|  | 108 | +```css | 
|  | 109 | +/* Specifies the end position of a grid item along the block (column) axis. */ | 
|  | 110 | +.item { | 
|  | 111 | +  grid-row-end: 3; | 
|  | 112 | +} | 
|  | 113 | +``` | 
|  | 114 | + | 
|  | 115 | +## Grid Area | 
|  | 116 | +```css | 
|  | 117 | +/* Specifies both the start and end positions of a grid item. */ | 
|  | 118 | +.item { | 
|  | 119 | +  grid-area: 1 / 1 / 3 / 3; | 
|  | 120 | +} | 
|  | 121 | +``` | 
|  | 122 | + | 
|  | 123 | +## Justify Self | 
|  | 124 | +```css | 
|  | 125 | +/* Aligns a grid item along the inline (row) axis. */ | 
|  | 126 | +.item { | 
|  | 127 | +  justify-self: center; | 
|  | 128 | +} | 
|  | 129 | +``` | 
|  | 130 | + | 
|  | 131 | +## Align Self | 
|  | 132 | +```css | 
|  | 133 | +/* Aligns a grid item along the block (column) axis. */ | 
|  | 134 | +.item { | 
|  | 135 | +  align-self: center; | 
|  | 136 | +} | 
|  | 137 | +``` | 
|  | 138 | + | 
|  | 139 | +## Learn More about CSS Grid from here: | 
|  | 140 | +https://css-tricks.com/snippets/css/complete-guide-grid/ | 
|  | 141 | +[](https://www.youtube.com/watch?v=ULp7wPJ-rzQ&ab_channel=VishalRajput "CSS Grid Tutorial for Beginners") | 
0 commit comments