JSFiddle - React, Tailwind, and code Playground
by otunik
HTML
<div class="grid-container">
<div class="header">
A quick example of CSS Grid
</div>
<div class="sidebar-left">
sidebar goes left
</div>
<div class="content">
main content
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<div class="sidebar-right">
sidebar goes right
</div>
<div class="promo">
below right sidebar
</div>
<div class="footer">
across entire width
</div>
</div>
CSS
.grid-container {
display: grid;
grid-template-columns: auto;
grid-template-rows: auto;
grid-column-gap: 3px;
grid-row-gap: 3px;
justify-items: stretch;
align-content: center;
align-items: start;
grid-template-areas:
"header header header"
"sidebar-left content sidebar-right"
"sidebar-left content promo"
"footer footer footer"
}
.header {
grid-area: header;
}
.sidebar-left {
grid-area: sidebar-left;
}
.content {
grid-area: content;
}
.sidebar-right {
grid-area: sidebar-right;
}
.promo {
grid-area: promo;
}
.footer {
grid-area: footer;
}
@media (max-width: 500px) {
.grid-container {
grid-template-columns: auto;
grid-template-rows: auto;
grid-template-areas:
"header"
"content"
"sidebar-left"
"sidebar-right"
"promo"
"footer"
}
}
.header {
background: yellow;
}
.sidebar-left {
background: #BADA55;
}
.content {
background: #C0FFEE;
}
.sidebar-right {
background: #C55;
}
.promo {
background: #D3C0D3;
}
.footer {
background: #BEE;
}