CSS align-items Property
Example
Center the alignments for all the items of the flexible <div> element:
div
{
display: flex;
align-items: center;
}
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The align-items
property specifies the default alignment for items inside the flexible container.
Tip: Use the align-self property of each item to override the align-items
property.
Default value: | stretch |
---|---|
Inherited: | no |
Animatable: | no. Read about animatable |
Version: | CSS3 |
JavaScript syntax: | object.style.alignItems="center" Try it |
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Numbers followed by -webkit- specify the first version that worked with a prefix.
Property | |||||
---|---|---|---|---|---|
align-items | 21.0 | 11.0 | 20.0 | 9.0 7.0 -webkit- |
12.1 |
CSS Syntax
align-items: stretch|center|flex-start|flex-end|baseline|initial|inherit;
Property Values
Value | Description | Play it |
---|---|---|
stretch | Default. Items are stretched to fit the container | Demo ❯ |
center | Items are positioned at the center of the container | Demo ❯ |
flex-start | Items are positioned at the beginning of the container | Demo ❯ |
flex-end | Items are positioned at the end of the container | Demo ❯ |
baseline | Items are positioned at the baseline of the container | Demo ❯ |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
More Examples
Example
Items are positioned at the beginning of the container:
div {
display: flex;
align-items: flex-start;
}
Try it Yourself »
Example
Items are positioned at the end of the container:
div {
display: flex;
align-items: flex-end;
}
Try it Yourself »
Example
Items are positioned at the baseline of the container:
div {
display: flex;
align-items: baseline;
}
Try it Yourself »
Example
Items are stretched to fit the container:
div {
display: flex;
align-items: stretch;
}
Try it Yourself »
Related Pages
CSS Reference: align-content property
CSS Reference: align-self property
HTML DOM reference: alignItems property