下面有更多 "亲自试一试" 示例。
这个place-self
property 用于对齐各个网格项,并且是以下属性的简写属性:
如果 place-self 属性有两个值:
如果 place-self 属性只有一个值:
表中的数字指定完全支持该属性的第一个浏览器版本。
Property | |||||
---|---|---|---|---|---|
place-self | 59.0 | 79.0 | 45.0 | 11.0 | 46.0 |
place-self: auto|
value|initial|inherit;
Value | Description | Demo |
---|---|---|
auto | Default. The element's default place-self value. | Demo ❯ |
normal | Dependant on layout context, but similar to 'stretch' for grid layout for grid items when size is not set. If size is set, the property value behaves lik 'start'. | Demo ❯ |
stretch | Stretches to fill the grid cell if size is not set. | Demo ❯ |
start | Align items at the start in the inline and block directions | Demo ❯ |
left | Align items to the left in the inline direction, as the justify-self property value. | Demo ❯ |
center | Align items to the center | Demo ❯ |
end | Align items at the end in the inline and block directions | Demo ❯ |
right | Align items to the right in the inline direction, as the justify-self property value. | Demo ❯ |
overflow-alignment |
|
|
baseline alignment | The element is aligned with the baseline of the parent. | Demo ❯ |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
随着writing-mode
<div>元素的属性值设置为'vertical-rl',块方向网格单元的末端从下向左移动,内联方向网格单元的末端从右向左移动底部:
#contianer {
display: grid;
writing-mode: vertical-rl;
}
#myDiv {
place-self: end;
}
亲自试一试 »
这个place-self
属性也可用于 Flexbox 项目,但第二个值用于justify-self
将被忽略,因为它不适用于 Flexbox:
#contianer {
display: flex;
}
#myDiv {
place-self: end stretch;
}
亲自试一试 »
CSS教程:CSS 网格
CSS教程:CSS 弹性盒
CSS 自我对齐属性:CSS 自我对齐属性
CSS justitfy-self 属性:CSS justify-self 属性
CSS 写入模式属性:CSS 书写模式属性
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!