Grid layout basic concepts
- Areas that use a grid layout are called containers.
- Inside the container, grid-positioned child elements are called “items”.
- The horizontal areas inside the container are called rows, and the vertical areas are called columns.
- The area where rows and columns intersect is called a cell.
- The lines that divide a grid are called grid lines.
- The horizontal grid line divides the travel, and the vertical grid line divides the train.
- Under normal circumstances,
n
Row hasn + 1
Root horizontal grid line,m
List ofm + 1
Root vertical grid lines, such as three rows have four horizontal grid lines.
Grid layout properties fall into two categories. One class is defined on the container and is called container properties. The other category is defined on a project and is called project attributes.
Container attribute
The display properties
Specify a container with a grid layout.
display: grid
Specify a container with a grid layout.display: inline-grid
Sets container elements to inline elements.
Grid-template-columns and grid-template-rows attributes
Once the container has specified the grid layout, the next step is to partition the rows and columns.
grid-template-columns
Property defines the column width for each columngrid-template-rows
Property defines the row height for each row.
- repeat()
- Auto – the fill keywords
- Fr keyword
- minmax()
- The auto keyword
- The name of the grid line
- Layout instance
Grid-row-gap, grid-column-gap, grid-gap
grid-row-gap
Property to set the row spacing (row spacing),grid-column-gap
Property sets the interval between columns (column spacing).grid-gap
Attributes aregrid-column-gap
andgrid-row-gap
The syntax is as follows.
The grid – the template – areas attribute
Grid layouts allow you to specify “areas”, an area consisting of one or more cells. The grid-template-Areas attribute is used to define areas.
The grid – auto – flow properties
- This order is determined by
grid-auto-flow
Property determines that the default value isrow
, that is, “first, second”. Or I could set it to becolumn
, becomes “first in line, then in line”. grid-auto-flow
Property except set torow
andcolumn
, can also be set torow dense
andcolumn dense
. These two values are mainly used for how the remaining items are automatically placed after certain items are specified.
Context-items, align-items, place-items
justify-items
Property sets the horizontal position of cell contents (left, middle and right)align-items
Property sets the vertical position of cell contents (top, middle, and bottom)place-items
Attributes arealign-items
Properties andjustify-items
The merged short form of a property.
Context-content, align-content, place-content
justify-content
Property is the horizontal position of the entire content area in the container (left, middle, and right)align-content
Property is the vertical position (top, middle, bottom) of the entire content area.place-content
Attributes arealign-content
Properties andjustify-content
The merged short form of a property.
Grid-template property, grid property
grid-template
Attributes aregrid-template-columns
,grid-template-rows
andgrid-template-areas
The combined short form of these three properties.grid
Attributes aregrid-template-rows
,grid-template-columns
,grid-template-areas
,grid-auto-rows
,grid-auto-columns
,grid-auto-flow
The combined short form of these six properties.
The project properties
Grid-column-start attribute, grid-column-end attribute, grid-row-start attribute, grid-row-end attribute
The location of an item can be specified by specifying which grid line is located on each of the four borders of the item.
grid-column-start
Property: Vertical gridline with the left bordergrid-column-end
Property: Vertical gridline on which the right border is locatedgrid-row-start
Property: horizontal gridline on which the top border is locatedgrid-row-end
Property: horizontal gridline on which the bottom border is located
Grid-column property, grid-row property
grid-column
Attributes aregrid-column-start
andgrid-column-end
The combined short form ofgrid-row
Attributes aregrid-row-start
Properties andgrid-row-end
The combined short form of.
The grid – area property
The grid-area property specifies which area the project is placed in.
Context-self, align-self, place-self
justify-self
Property sets the horizontal position of the cell’s contents (left, middle, and right), andjustify-items
Attributes are used exactly the same, but only for a single project.align-self
Property sets the vertical position of the cell’s contents (top, middle, bottom), andalign-items
Attributes are used exactly the same and apply only to a single item.place-self
Attributes arealign-self
Properties andjustify-self
The merged short form of a property.
Refer to the link: www.ruanyifeng.com/blog/2019/0…