Skip to content

Instantly share code, notes, and snippets.

@thinsoldier
Last active November 29, 2018 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinsoldier/f7e4952c83d89c2f19f1ae0b6855b454 to your computer and use it in GitHub Desktop.
Save thinsoldier/f7e4952c83d89c2f19f1ae0b6855b454 to your computer and use it in GitHub Desktop.
jere - css grid demo
<div class="container-1">
<div class="box big-box" style="background-image:url(https://tech-ranking.a2hosted.com/wp-content/uploads/2018/11/Minecraft-Pillager-Outpost.jpg);">
<h2>Minecraft 1.14: Pillager Outpost seed</h2>
</div>
<div class="box" style="background-image:url(https://tech-ranking.a2hosted.com/wp-content/uploads/2018/10/Minecraft-Bamboo-Jungle-1.jpg);">
<h2>Minecraft 1.14 Bamboo Jungle Seed – The first ever bamboo forest seed for 1.14!</h2></div>
<div class="box" style="background-image:url(https://tech-ranking.a2hosted.com/wp-content/uploads/2018/09/Minecraft-1.13-Shaders-Comparison.jpg);">
<h2>Best shaders for Minecraft 1.13 Java (2018)</h2></div>
<div class="box" style="background-image:url(https://tech-ranking.a2hosted.com/wp-content/uploads/2018/09/Dimmer-Android-screen-than-minimum.jpg);">
<h2>How to make your Android screen dimmer or darker than minimum</h2></div>
<div class="box" style="background-image:url(https://tech-ranking.a2hosted.com/wp-content/uploads/2018/07/The-best-Reddit-app-alternatives.jpg);">
<h2>The best Reddit app alternatives of 2018 (Android)</h2></div>
</div>
* { box-sizing: border-box; }
html, body { margin:0; padding:0; }
/* wraps the entire thing */
.container-1 {
display: grid;
grid-auto-rows: 200px;
grid-gap: 5px;
}
.box {
background-size: cover;
background-position: center;
padding: 0 0 10px 10px;
color: white;
font-size: 22px;
/* push text to the bottom */
display:flex;
align-items: flex-end;
}
.big-box { /* enhances .box */
grid-row: 1 / span 2;
font-size: 32px;
}
.box > h2 { /* only applies to h2 that are children of .box */
margin:0;
color:white;
font-weight: normal;
font-size: inherit;
text-shadow: 0px 0px 2px black, 0px 0px 5px black;
}
@media screen and (min-width: 360px){
.container-1 {
grid-template-columns: repeat(2,1fr);
}
.big-box {
grid-column: 1 / -1;
grid-row: 1;
}
}
@media screen and (min-width: 768px){
.container-1{
max-width: 1170px;
margin: auto;
grid-template-columns: repeat(4,1fr);
grid-template-rows: repeat(2,200px);
}
.big-box {
grid-row: 1 / span 2;
grid-column: 1 / span 2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment