# align-self

CSS 属性 align-self 会对齐当前 grid 或 flex 行中的元素,并覆盖已有的 align-items 的值。In Grid, it aligns the item inside the grid area. 在 Flexbox 中,会按照 cross axis(当前 flex 元素排列方向的垂直方向)进行排列。

# uni-app x 兼容性

Android iOS web
3.9 4.11 4.0

# 语法

align-self: auto | normal | stretch | <baseline-position> | <overflow-position>? <self-position>;

# align-self 的属性值

auto 设置为父元素的 align-items 值。

center flex 元素会对齐到 cross-axis 的中间,如果该元素的 cross-size 尺寸大于 flex 容器,将在两个方向均等溢出。

flex-start flex 元素会对齐到 cross-axis 的首端。

flex-end flex 元素会对齐到 cross-axis 的尾端。

stretch 如果元素未设置高度或设为auto,将占满整个容器的高度。

baseline Specifies participation in first- or last-baseline alignment: aligns the alignment baseline of the box’s first or last baseline set with the corresponding baseline in the shared first or last baseline set of all the boxes in its baseline-sharing group. The fallback alignment for first baseline is start, the one for last baseline is end. flex 元素将会基于容器的宽和高,按照自身 margin box 的 cross-size 拉伸。If the combined size of the items along the cross axis is less than the size of the alignment container and the item is 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.

# 默认值

auto

# 兼容性

# align-self 的属性值兼容性

Android iOS web
auto 3.9 4.11 4.0
center 3.9 4.11 4.0
flex-start 3.9 4.11 4.0
flex-end 3.9 4.11 4.0
stretch 3.9 4.11 4.0
baseline x x 4.0

# 浏览器兼容性

Chrome Edge Firefox Opera Safari IE
align-self √( 29 ) √( 12 ) √( 20 ) √( 12.1 ) √( 9 ) √( 10 )

# 参见