示例工程 17-grid-areas
17-grid-areas/demo-01-named-areas/style.css
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
body {
margin: 0;
padding: 32px;
background: #f8fafc;
color: #0f172a;
font-family: system-ui, sans-serif;
line-height: 1.7;
}
h1 {
margin: 0 0 8px;
font-size: 26px;
}
.layout {
display: grid;
grid-template-areas:
"head head head"
"nav main aside"
"foot foot foot";
grid-template-columns: 120px minmax(0, 1fr) 120px;
grid-template-rows: 64px 180px 56px;
gap: 10px;
max-width: 720px;
margin-top: 16px;
padding: 10px;
border: 1px dashed #cbd5e1;
border-radius: 10px;
background: #ffffff;
}
.box {
display: grid;
place-items: center;
border-radius: 8px;
color: #ffffff;
font-size: 12px;
font-family: ui-monospace, monospace;
}
.head { grid-area: head; background: #2563eb; }
.nav { grid-area: nav; background: #7c3aed; }
.main { grid-area: main; background: #0f172a; }
.aside { grid-area: aside; background: #db2777; }
.foot { grid-area: foot; background: #475569; }