CSS align-self Property
Example
Centers an item within a flexbox element:
#myBlueDiv
{
align-self:
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-self | 21.0 | 11.0 | 20.0 | 9.0 | |
| 7.0 -webkit- | 12.1 |
Definition and Usage
The align-self property defines the alignment of an individual flex item along the cross axis (vertical).
**Note:** The align-self property can override the align-items property of a flex container.
| Default value: | auto |
|---|---|
| Inherited: | No |
| Animatable: | No. See Animatable. |
| Version: | CSS3 |
| JavaScript syntax: | object.style.alignSelf="center" Try it |
CSS Syntax
align-self: auto|stretch|center|flex-start|flex-end|baseline|initial|inherit;
Attribute values
| Value | Description | Testing |
|---|---|---|
| auto | Default. The element inherits the align-items property of its parent container. If there is no parent container, it is "stretch". | Test » |
| stretch |
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-items Property
CSS Reference Manual