«Holy Grail» using CSS Grid
grid-gap = shorthand for
<!— HTML —> <div class=”grid grid—grail”> <header class=”grid__item header”>Header</header> <article class=”grid__item content”>Content</article> <div class=”grid__item sidebar1”>Sidebar 1</div> <div class=”grid__item sidebar2”>Sidebar 2</div> <footer class=”grid__item footer”>Footer</footer> </div> // SCSS .grid—grail { grid-template-columns: 300px 1fr 300px; grid-template-rows: auto; grid-column-gap: 20px;
grid-column-gap + grid-row-gap
}
.header .content .sidebar1 .sidebar2 .footer
{ { { { {
grid-column: grid-column: grid-column: grid-column: grid-column:
1 2 1 3 1
/ / / / /
4; 3; 2; 4; 4;
} grid-row: grid-row: grid-row: grid-row:
2 2 2 3
/ / / /
3; 3; 3; 4;
} } } }