What is the CSS property align-items used for and what values can it have?
Experience Level: Junior
Tags: CSSFlexbox
Answer
The align-items
defines the alignment of the flex items within the flex-container when the items are wrapped/when there are multiple rows (or columns) on the main axis.
The property can have the following values:
stretch
- items are stretched to fit the containercenter
- items are positioned at the center of the containerflex-start
- items are positioned at the beginning of the containerflex-end
- items are positioned at the end of the containerbaseline
- items are positioned at baseline of the container
div {
display: flex;
align-items: center;
}
Related Flexbox job interview questions
What does the align-content CSS property do and when do you use it?
CSSFlexbox JuniorHow can you make flex container items that flow from left to right to fill all space from top to bottom?
CSSFlexbox JuniorWhat is a cross axis in Flexbox?
CSSFlexbox JuniorHow would you use space-between and what do you know about it?
CSSFlexbox JuniorWhy would you use flex-wrap CSS property and what values can it have?
CSSFlexbox Junior