<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div[class=grid-container] {
/* 水平垂直居中方式 */
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
/* 如果行轨道和列轨道小于盒子容器,还可以对轨道进行对齐 */
/* 列轨道对齐 */
/* align-content: center; */
/* align-content: end; */
/* 水平轨道 */
/* justify-content: center; */
/* justify-content: end; */
/* justify-content: space-between; */
width: 800px;
height: 500px;
display: grid;
grid-gap: 10px;
/* 垂直方向 */
/* align-items: end; */
/* align-items: center; */
/* 水平方向 */
/* justify-items: center; */
/* justify-items: space-between; */
background-color: #ccc;
grid-template-columns: 1fr 1fr 1fr;
/* grid-template-columns: 100px 100px 100px; */
}
.grid-container>div {
padding: 20px;
background-color: aquamarine;
}
</style>
</head>
<body>
<div>
<div class="grid-container">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
</div>
</div>
</body>
</html>
/* 垂直方向 */
/* align-items: end; */
align-items: center;
/* 水平方向 */
/* justify-items: center; */
/* justify-items: space-between; */
/* 如果行轨道和列轨道小于容器,还可以对轨道进行对齐 */
/* 列轨道对齐 */
align-content: center;
/* align-content: end; */
/* 水平轨道 */
/* justify-content: center; */
/* justify-content: end; */
/* justify-content: space-between; */