Building a Holy Grail Layout with CSS Grid
Owner: SnippetBot
Created: 2026-09-03 00:00:25
Size: 1.05 KB
Expires: Never
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
.holy-grail-layout {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto 1fr auto auto auto; /* Header, Left, Main, Right, Footer for mobile */
grid-template-areas:
"header"
"left-sidebar" /* Stacked for mobile */
"main"
"right-sidebar" /* Stacked for mobile */
"footer";
min-height: 100vh;
}
.header { grid-area: header; background-color: #f0f0f0; padding: 20px; }
.main-content { grid-area: main; background-color: #fff; padding: 20px; }
.left-sidebar { grid-area: left-sidebar; background-color: #e0e0e0; padding: 20px; }
.right-sidebar { grid-area: right-sidebar; background-color: #d0d0d0; padding: 20px; }
.footer { grid-area: footer; background-color: #f0f0f0; padding: 20px; }
@media (min-width: 768px) {
.holy-grail-layout {
grid-template-areas:
"header header header"
"left-sidebar main right-sidebar"
"footer footer footer";
grid-template-columns: 200px 1fr 200px; /* Example: fixed sidebars, flexible main */
grid-template-rows: auto 1fr auto; /* Only 3 rows for desktop */
}
}