The CSS align-items
property is used to align children elements inside a flex or grid container element. align-items
sets the align-self
value on all direct children as a group.
In Flexbox, it controls the alignment of items on the Cross Axis. In Grid Layout, it controls the alignment of items on the Block Axis within their grid area.
align-items: stretch|center|start|end|baseline|initial|inherit;
Default value: stretch
.
For the list of all possible values, check out the official docs.
We make the container a Flexbox by setting display: flex
. Next, we set the align-items
property to the center
value, which aligns each div
item in the center.
Try experimenting with different values like
stretch
andstart
foralign-items
.
Free Resources