English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The align-The self property specifies the default alignment for elements within a flex container.
The following table summarizes the usage context and version history of this property.
Default value: | auto |
---|---|
Applies to: | Flexible elements, including the pseudo-elements that flow in |
Inheritance: | None |
Animatable: | No.See also Animation properties. |
Version: | CSS3new feature |
JavaScript syntax: | object.style.alignItems="center" |
The syntax of this attribute is as follows:
align-self: auto | baseline | center | flex-start | flex-end | stretch | initial | inherit
The following example shows how to use align-self property.
.flex-container { /* Safari */ display: -webkit-flex; -webkit-align-items: flex-start; display: flex; align-items: flex-start; } .aligned { /* Safari */ -webkit-flex: 1; -webkit-align-self: stretch; flex: 1; align-self: stretch; }Test to see‹/›
The following table describes the value of this attribute.
Value | Description |
---|---|
auto | The element uses the calculated value of the align attribute of its parent element.-If items has no parent element, it uses stretch. This is the default value. |
baseline | The element is at the baseline of the flex container. |
center | The element is at the center of the flex container. |
flex-start | The element is at the beginning of the flex container. |
flex-end | The element is at the end of the flex container. |
stretch | Stretch the element to fit the flex container. |
initial | Set this property to its default value. |
inherit | If specified, the associated elements will use the calculated value of the align attribute of its parent element.-self. |
align-browser compatibility of the self property, all major browsers support this property.
|
Note: Apple Safari 7and higher versions to support the align-self property, but it needs-webkit-prefix, for example-webkit-align-self: center;
Please refer to the following tutorials:CSS Alignment.
Related Attributes:align-content,align-items,display,flex,flex-basis,flex-direction,flex-flow,flex-grow,flex-shrink,flex-wrap,justify-content,min-height,min-width,order.