<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>网格布局测试</title>
<link rel="stylesheet" href="grid-css.css">
</head>
<body>
<div class="container">
<div class="header">头部</div>
<div class="left">内容左侧</div>
<div class="main">内容中间</div>
<div class="right">内容右侧</div>
<div class="footer">底部</div>
</div>
</body>
</html>
grid-css.css
.container {
display: grid;
grid-template-columns: 200px auto 200px;
grid-template-rows: 100px 500px 100px;
}
.header,.footer{
grid-column: 1 / 4;
background-color: lightblue;
text-align: center;
}
.main {
background-color: lightgreen;
text-align: center;
}
.left {
background-color: lightcoral;
text-align: center;
}
.right {
background-color: lightcoral;
text-align: center;
}