CSS Grid
- Grid
- Grid - Shorthand
.container {
margin: 20px;
display: grid;
height: 100vh;
/* grid-template-columns: 200px 2fr 20% 1fr; */
grid-template-columns: repeat(4, [col-start] 20% [col-end]);
/* grid-template-rows: 5rem minmax(3rem, 5.5rem); */
/* rows with names */
grid-template-rows: [row-1-start] 5rem [row-1-end row-2-start] minmax(3rem, 5.5rem) [row-2-end];
column-gap: 10px;
row-gap: 10px;
/* justifying inner items in grid */
justify-items: stretch;
align-items: stretch;
/* justifying the grid */
justify-content: center;
align-content: center;
}
.container {
margin: 20px;
display: grid;
height: 100vh;
/* grid-template-columns: 200px 2fr 20% 1fr; */
grid-template-columns: repeat(4, [col-start] 20% [col-end]);
/* grid-template-rows: 5rem minmax(3rem, 5.5rem); */
/* rows with names */
grid-template-rows: [row-1-start] 5rem [row-1-end row-2-start] minmax(3rem, 5.5rem) [row-2-end];
gap: 10px;
/* justifying inner items in grid */
justify-items: stretch;
align-items: stretch;
/* justifying the grid */
justify-content: center;
align-content: center;
}
- Grid Item
- Grid Item - Shorthand
.el3 {
background: rgba(0, 128, 0, 0.5);
grid-column-start: 3;
grid-column-end: 5;
/* grid-row-start: 1; */
grid-row-start: row-1-start;
grid-row-end: row-2-end;
justify-self: center;
align-self: center;
}
.el3 {
background: rgba(0, 128, 0, 0.5);
grid-column: 3 / 5;
grid-row: row-1-start / row-2-end;
grid-area: row-1-start / 3 / row-2-end / 5;
justify-self: center;
align-self: center;
}
GitHub Repo
- To view normal page - Demo :
http://localhost:5173/ - To view home page - Demo :
http://localhost:5173/home/ - To view media-query page - Demo :
http://localhost:5173/media-query/ - To view autoflow page - Demo :
http://localhost:5173/autoflow/