Skip to content

Instantly share code, notes, and snippets.

@JonathanChaochen
Created October 15, 2018 09:57
Show Gist options
  • Save JonathanChaochen/e3ee33f3177822efc28c1eb3b05dd31c to your computer and use it in GitHub Desktop.
Save JonathanChaochen/e3ee33f3177822efc28c1eb3b05dd31c to your computer and use it in GitHub Desktop.
css grid playaround
<div class="grid">
<div class="title">title</div>
<div class="header">header</div>
<div class="sidebar">sidebar</div>
<div class="content">content</div>
<div class="footer">footer</div>
</div>
.grid {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr 1fr;
grid-gap: 4px;
grid-template-areas:
'title title'
'header header'
'sidebar sidebar'
'content content'
'footer footer';
}
.title {
grid-area: title;
}
.header {
grid-area: header;
}
.sidebar {
grid-area: sidebar;
}
.content {
grid-area: content;
}
.footer {
grid-area: footer;
}
.grid div:nth-child(even) {
background-color: red;
}
.grid div:nth-child(odd) {
background-color: green;
}
@media screen and (min-width: 736px) {
.grid {
display: grid;
grid-template-columns: 1fr 500px 500px 1fr;
grid-template-rows: 1fr 1fr 1fr 1fr;
grid-template-areas:
'. title title .'
'. header header .'
'. sidebar content .'
'. footer footer .';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment