下面有更多 "亲自试一试" 示例。
这个align-items
属性指定 Flexbox 或网格容器内项目的默认对齐方式。
为了使此属性具有任何对齐效果,项目需要在适当的方向上围绕其自身留出可用空间。
提示:使用align-self
要覆盖的每个项目的属性align-items
属性。
表中的数字指定完全支持该属性的第一个浏览器版本。
Property | |||||
---|---|---|---|---|---|
align-items | 57.0 | 16.0 | 52.0 | 10.1 | 44.0 |
align-items: normal|stretch|
positional alignment|flex-start|flex-end|baseline|initial|inherit;
Value | Description | Play it |
---|---|---|
normal | Default. Behaves like 'stretch' for flexbox and grid items, or 'start' for grid items with a defined block size. | Demo ❯ |
stretch | Items are stretched to fit the container | Demo ❯ |
center | Items are positioned at the center of the container | Demo ❯ |
flex-start | Items are positioned at the beginning of the container | Demo ❯ |
flex-end | Items are positioned at the end of the container | Demo ❯ |
start | Items are positioned at the beginning of their individual grid cells, in the block direction | |
end | Items are positioned at the end of the their individual grid cells, in the block direction | |
baseline | Items are positioned at the baseline of the container | Demo ❯ |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
对于绝对定位的网格项目,项目在块方向上的每个网格单元的末尾对齐:
#container {
display: grid;
position: relative;
align-items: end;
}
#container > div {
position: absolute;
}
亲自试一试 »
CSS教程:CSS 网格
CSS教程:CSS 弹性盒
CSS 参考:对齐内容属性
CSS 参考:自我对齐属性
CSS 参考:调整内容属性
CSS 参考:证明项目属性
CSS 参考:证明自我属性
HTML DOM 参考:对齐项目属性
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!