The align-self
CSS property aligns flex items of the current flex line overriding the align-items
value. If any of the item's cross-axis margin is set to auto
, then align-self
is ignored. In Grid layout align-self
aligns the item inside the grid area.
The property doesn't apply to block-level boxes, or to table cells.
/* Keyword values */ align-self: auto; align-self: normal; /* Positional alignment */ /* align-self does not take left and right values */ align-self: center; /* Put the item around the center */ align-self: start; /* Put the item at the start */ align-self: end; /* Put the item at the end */ align-self: self-start; /* Align the item flush at the start */ align-self: self-end; /* Align the item flush at the end */ align-self: flex-start; /* Put the flex item at the start */ align-self: flex-end; /* Put the flex item at the end */ /* Baseline alignment */ align-self: baseline; align-self: first baseline; align-self: last baseline; align-self: stretch; /* Stretch 'auto'-sized items to fit the container */ /* Overflow alignment */ align-self: safe center; align-self: unsafe center; /* Global values */ align-self: inherit; align-self: initial; align-self: unset;
auto
align-items
value.normal
start
on replaced absolutely-positioned boxes, and as stretch
on all other absolutely-positioned boxes.stretch
.stretch
.stretch
, except for boxes with an aspect ratio or an intrinsic sizes where it behaves like start
.self-start
self-end
flex-start
flex-end
center
baseline
first baseline
last baseline
first baseline
is start
, the one for last baseline
is end
.stretch
auto
-sized, its size is increased equally (not proportionally), while still respecting the constraints imposed by max-height
/max-width
(or equivalent functionality), so that the combined size of all auto
-sized items exactly fills the alignment container along the cross axis.safe
start
.unsafe
auto | normal | stretch | <baseline-position> | <overflow-position>? <self-position>where
<baseline-position> = [ first | last ]? baseline
<overflow-position> = unsafe | safe
<self-position> = center | start | end | self-start | self-end | flex-start | flex-end
<section> <div>Item #1</div> <div>Item #2</div> <div>Item #3</div> </section>
section { display: flex; align-items: center; height: 120px; background: beige; } div { height: 60px; background: cyan; margin: 5px; } div:nth-child(3) { align-self: flex-end; background: pink; }
Specification | Status | Comment |
---|---|---|
CSS Box Alignment Module Level 3 The definition of 'align-self' in that specification. | Working Draft | Update to latest syntax definitions. |
CSS Flexible Box Layout Module The definition of 'align-self' in that specification. | Candidate Recommendation | Initial definition. |
Initial value | auto |
---|---|
Applies to | flex items, grid items, and absolutely-positioned boxes |
Inherited | no |
Media | visual |
Computed value |
auto computes to itself on absolutely-positioned elements, and to the computed value of align-items on the parent (minus any legacy keywords) on all other boxes, or start if the box has no parent. Its behavior depends on the layout model, as described for justify-self . Otherwise the specified value. |
Animation type | discrete |
Canonical order | the unique non-ambiguous order defined by the formal grammar |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 36
|
12 | 20
|
11 | 12.1 | No |
start and end
|
? | ? | Yes | ? | ? | ? |
left and right
|
? | ? | 52 | ? | ? | ? |
baseline |
? | ? | Yes | ? | ? | ? |
first baseline and last baseline
|
? | ? | 52 | ? | ? | ? |
stretch |
? | ? | 52 | ? | ? | ? |
safe and unsafe
|
No | No | 63 | No | No | ? |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | 37
|
36
|
Yes
|
Yes | No | No | ? |
start and end
|
? | ? | ? | ? | ? | ? | ? |
left and right
|
? | ? | ? | 52 | ? | ? | ? |
baseline |
? | ? | ? | Yes | ? | ? | ? |
first baseline and last baseline
|
? | ? | ? | 52 | ? | ? | ? |
stretch |
? | ? | ? | 52 | ? | ? | ? |
safe and unsafe
|
? | ? | No | 63 | ? | ? | No |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 57 | 16 | 52 | 10
|
44 | 10.1 |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | 57 | 52 | Yes | 52 | 44 | 10.3 | 6.2 |
align-items
property
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/align-self