Created
October 15, 2018 09:57
-
-
Save JonathanChaochen/e3ee33f3177822efc28c1eb3b05dd31c to your computer and use it in GitHub Desktop.
css grid playaround
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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