English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS reference manual

CSS @rules

CSS attributes大全

CSS3 align-Usage and examples of the self property

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"

align-self usage syntax

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‹/›

Attribute Value

The following table describes the value of this attribute.

ValueDescription
autoThe 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.
baselineThe element is at the baseline of the flex container.
centerThe element is at the center of the flex container.
flex-startThe element is at the beginning of the flex container.
flex-endThe element is at the end of the flex container.
stretchStretch the element to fit the flex container.
initialSet this property to its default value.
inheritIf specified, the associated elements will use the calculated value of the align attribute of its parent element.-self.

Browser Compatibility

align-browser compatibility of the self property, all major browsers support this property.

  • Firefox 20+

  • Google Chrome21+

  • Internet Explorer 11+

  • Apple Safari 7+ -webkit-

  • Opera 12.1+

Note: Apple Safari 7and higher versions to support the align-self property, but it needs-webkit-prefix, for example-webkit-align-self: center;

Read More

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.