The align-self
property is a sub-property of the Flexible Box Layout module.
It makes possible to override the align-items
value for specific flex items.
The align-self
property accepts the same 5 values as the align-items
:
flex-start
: cross-start margin edge of the item is placed on the cross-start lineflex-end
: cross-end margin edge of the item is placed on the cross-end linecenter
: item is centered in the cross-axisbaseline
: items are aligned such as their baseline are alignedstretch
(default): stretch to fill the container (still respect min-width/max-width)
Syntax
align-self: auto | flex-start | flex-end | center | baseline | stretch
.flex-item {
align-self: flex-end;
}
Demo
The following demo shows how an item can align itself in the flex container depending on the align-self
value:
- The 1st item is set to
flex-start
- The 2nd item is set to
flex-end
- The 3rd item is set to
center
- The 4th item is set to
baseline
- The 5th item is set to
stretch
See the Pen align-self demo by CSS-Tricks (@css-tricks) on CodePen.
Related Properties
Other Resources
- align-self in the spec
- align-self at MDN
- Advanced cross-browser flexbox
- A guide to Flexbox
- Using Flexbox
- Old Flexbox and new Flexbox
Browser Support
This browser support data is from Caniuse, which has more detail. A number indicates that browser supports the feature at that version and up.
Desktop
Chrome | Firefox | IE | Edge | Safari |
---|---|---|---|---|
21* | 28 | 11 | 12 | 6.1* |
Mobile / Tablet
Android Chrome | Android Firefox | Android | iOS Safari |
---|---|---|---|
123 | 124 | 4.4 | 7.0-7.1* |
For more informations about how to mix syntaxes in order to get the best browser support, please refer to this article (CSS-Tricks) or this article (DevOpera).
I think the support table on this article might not be entirely accurate — I can’t find the corollary for old flexbox (display: box;) for this property. Am I missing something?
I also think the support table is a bit weird here. I don’t think Safari supports align-self
Yes, even i faced this. Safari does not support align-self
Safari supports it on 7.0+ with -webkit-align-self
http://www.w3schools.com/cssref/css3_pr_align-self.asp
Still not Working :(
Late to the party, but for Raj and anyone coming after me…
The -webkit solution works assuming you include the alternate styles for all your flex references. See a complete explanation here (https://css-tricks.com/using-flexbox/).
On the surface, it seems align-self:baseline; and align-self:flex-start do the same things. At least that’s the impression I get when I use either or on my website. I’m surely missing something. So can someone elaborate the differences between the two? Thanks in advance.
hello, i would to change the display date-year from top to bottom? it’s possible to do that in css