CSS align-items Property
Example
Centers the items of the flexbox
div
{
display:
flex
;
align-items:
center
;
}
Try it »
Browser support
The numbers in the table indicate the version number of the first browser that supports this property.
The number immediately following -webkit-, -ms-, or -moz- is the first version that supports the prefixed property.
| property | |||||
|---|---|---|---|---|---|
| align-items | 21.0 | 11.0 | 20.0 | 9.0 | |
| 7.0 -webkit- | 12.1 |
Definition and Usage
The align-items property defines the alignment of flex items along the cross axis (vertical) of the current line in a flex container.
**Tip:** Use the align-self property of each flex item element to override the align-items property.
| Default value: | stretch |
|---|---|
| Inherited: | No |
| Animatable: | No. See Animatable. |
| Version: | CSS3 |
| JavaScript syntax: | object.style.alignItems="center" Try it |
CSS Syntax
align-items: stretch|center|flex-start|flex-end|baseline|initial|inherit;
Attribute values
| Value | Description | Testing |
|---|---|---|
| stretch |
Default value. The element is stretched to fit the container. If the property specifying the cross-axis size has the value 'auto', its value makes the item's margin box as close as possible to the size of its line, while still respecting the constraints of the 'min/max-width/height' properties. |
Test » |
| center |
The element is located at the center of the container. The flexbox item is centered along the cross axis (vertical) of the line. (If the line's size is smaller than the flexbox item's size, it will overflow equally in both directions.) |
Test » |
| flex-start |
The element is located at the beginning of the container. The cross-start (vertical) edge of the flexbox item is flush with the cross-start edge of the line. |
Test » |
| flex-end |
The element is located at the end of the container. The cross-start (vertical) edge of the flexbox item is flush with the cross-end edge of the line. |
Test » |
| baseline |
The element is located at the baseline of the container. If the inline axis and cross axis of the flexbox item are the same, this value is equivalent to 'flex-start'. Otherwise, this value participates in baseline alignment. |
Test » |
| initial | Sets this property to its default value. See initial. | Test » |
| inherit | Inherits this property from its parent element. See inherit. |
Related Articles
CSS Reference Manual:align-content Property
CSS Reference Manual:align-self Property
CSS Reference Manual