my_blog
my_blog copied to clipboard
CSS 006:CSS如何进行圣杯布局 新增 Grid 布局方法
trafficstars
<!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>
header {
height: 100px;
line-height: 100px;
text-align: center;
color: #fff;
background: red;
}
footer {
height: 100px;
line-height: 100px;
text-align: center;
color: #fff;
background: red;
}
main {
display: grid;
height: 200px;
line-height: 200px;
text-align: center;
grid-template-columns: 200px auto 200px; // 此处可以使用 template-columns 属性对列进行划分
}
aside {
background: yellow;
}
article {
color: #fff;
background: #1890ff;
}
</style>
</head>
<body>
<header>这是头部</header>
<main>
<aside>左边栏</aside>
<article>文章</article>
<aside>右边栏</aside>
</main>
<footer>这是页脚</footer>
</body>
</html>
效果如下图:

好的