Skip to content

Instantly share code, notes, and snippets.

@5t3ph
Last active January 24, 2021 15:02
Show Gist options
  • Save 5t3ph/9b3553c38acbdae8848b2634c17b4423 to your computer and use it in GitHub Desktop.
Save 5t3ph/9b3553c38acbdae8848b2634c17b4423 to your computer and use it in GitHub Desktop.
span {
border: 2px dashed currentcolor;
border-radius: 4px;
min-height: 15vh;
padding: 1rem;
color: #0178d4;
font-size: 3rem;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}
div:nth-child(2) span {
color: purple;
}
div:nth-child(3) span {
color: green;
}
div:nth-child(4) span {
color: orangered;
}
<main class="grid-wrap">
<div class="grid">
<span>One column default</span>
</div>
<div class="grid">
<span>Half column 1</span>
<span>Half column 2</span>
</div>
<div class="grid">
<span>3-col 1</span>
<span>3-col 2</span>
<span>3-col 3</span>
</div>
<div class="grid">
<span>4-col 1</span>
<span>4-col 2</span>
<span>4-col 3</span>
<span>4-col 4</span>
</div>
</main>
$minColWidth: 15rem;
$gridGap: 2rem;
.grid-wrap {
padding: $gridGap;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax($minColWidth, 1fr));
grid-gap: 2rem;
& + .grid {
margin-top: $gridGap;
}
}
@import "grid-item";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment