In the last article, we learned about some important terms related to CSS Grids including grid container and grid items. Now in next few articles, we are going to learn various properties of this grid elements. Let's begin...
display
It defines the element as a grid container and creates a new grid formatting for its elements.
Available values:
- grid - Creates a block-level grid
- inline-grid - Creates an inline-level grid
- subgrid - This is used to create nested grids. In this case, your grid container is itself a grid item of parent grid.
.container{
display: grid;
}
grid-template-columnsgrid-template-rows
It defines the columns and rows of the grid with the space-separated list of values. Here values will decide the size of each row/column and space between them represent a grid line.
Available values:
If you do not provide the names of lines CSS will automatically give them numerical names starting with 1.
.container{
display: grid;
grid-template-columns: 40px 50px auto 50px 40px;
grid-template-rows: 25% 100px auto;
}
.container{
display: grid;
grid-template-columns: [col1] 40px [col2] 50px [col3] auto [col4] 50px [col5] 40px [col6];
grid-template-rows: [row1] 25% [row2] 100px [row3] auto [row4];
}
If you have repeating parts, instead of writing completely you can use the following syntax:
.container{
grid-template-rows: repeat(4, 25px [row]) 5%;
}
.container{
grid-template-rows: 25px [row] 25px [row] 25px [row] 25px [row] 5%;
}
.container{
grid-template-rows: 1fr 1fr 1fr 1fr;
}
That's all for today. In the next article, we will continue learning properties related to CSS grids.
Till then #keepCoding.
Comments
Post a Comment