效果图:
代码:
HTML:
<!DOCTYPE html>
<html>
<head>
<title>布局</title>
<meta charset="utf-8">
</head>
<body>
<link rel="stylesheet" type="text/css" href="buju.css">
<div class="container">
<div class="one">One</div>
<div class="two">Two</div>
<div class="three">Three</div>
<div class="four">Four</div>
<div class="five">Five</div>
<div class="six">Six</div>
</div>
</body>
</html>
CSS:
.container{
display: grid;
grid-template-columns: 60px 60px 60px;
grid-auto-rows: 60px 60px 60px 60px;
background: white;
color: white;
}
.one{
grid-column-start: 1;
grid-row-start: 1;
grid-row-end: 2;
grid-column-end: 4;
background: red;
}
.two{
grid-column-start: 1;
grid-row-start: 2;
grid-column-end: 2;
grid-row-end: 5;
background: green;
}
.three{
grid-column-start: 2;
grid-row-start: 2;
grid-column-end: 3;
grid-row-end: 3;
background: black;
}
.four{
grid-column-start: 2;
grid-row-start: 3;
grid-row-end: 4;
grid-column-end: 3;
background: yellow;
}
.five{
grid-column-start: 2;
grid-row-start: 4;
grid-column-end: 3;
grid-row-end: 5;
background: red;
}
.six{
grid-column-start: 3;
grid-row-start: 2;
grid-column-end: 4;
grid-row-end: 5;
background:blue;
}