Web速查-索引

Alt text

定义

place-items 属性是 align-selfjustify-self 属性的缩写。

语法

place-self: align-self justify-self

align-self在前,justify-self在后。

实例

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>鱼C-零基础入门学习Web(Html5+Css3)</title>
<style>
.grid-container {
display: grid;
grid-template-columns: repeat(8, 1fr);
grid-auto-rows: 100px;
grid-template-areas:
"a a a a b b b b"
"a a a a b b b b"
"c c c c d d d d"
"c c c c d d d d";
grid-gap: 10px;
background-color: lightblue;
padding: 10px;
}
.grid-container>div {
background-color: lightpink;
}
.item1 {
grid-area: a;
}
.item2 {
grid-area: b;
place-self: center start;
}
.item3 {
grid-area: c;
place-self: end center;
}
.item4 {
grid-area: d;
}
</style>
</head>
<body>
<div class="grid-container">
<div class="item1">1</div>
<div class="item2">2</div>
<div class="item3">3</div>
<div class="item4">4</div>
</div>
</body>
</html>
1
2
3
4

浏览器支持

表格中的数字表示支持该属性的第一个浏览器版本号

Safari Chrome FireFox IE
3.1 4.0 3.0 8.0