简体中文
CSS 属性 align-self 会对齐当前 grid 或 flex 行中的元素,并覆盖已有的 align-items 的值。In Grid, it aligns the item inside the grid area. 在 Flexbox 中,会按照 cross axis(当前 flex 元素排列方向的垂直方向)进行排列。
Web | Android | iOS |
---|---|---|
4.0 | 3.9 | 4.11 |
align-self: auto | normal | stretch | <baseline-position> | <overflow-position>? <self-position>;
名称 | 兼容性 | 描述 |
---|---|---|
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