Skip to content

Instantly share code, notes, and snippets.

@vincentorback
Created May 25, 2018 09:52
Show Gist options
  • Save vincentorback/a6a2030b0de91d4640c2f79004cc179f to your computer and use it in GitHub Desktop.
Save vincentorback/a6a2030b0de91d4640c2f79004cc179f to your computer and use it in GitHub Desktop.
grid.css
.Grid {
--Grid-cell-width: 5em; /* Change this */
--Grid-gutter: 0.5em;
display: flex;
flex-wrap: wrap;
margin: calc(var(--Grid-gutter) * 0.5);
}
.Grid > * {
flex: 1 0 var(--Grid-width);
margin: var(--Grid-gutter);
}
.Grid > *:nth-child(5) {
flex-basis: 10em;
}
.Grid > *:first-child {
flex-basis: calc(100% - var(--Grid-gutter));
}
.Grid-wrap {
/* Use this for eg. margin styles around to not break the grid */
}
<div class="Grid-wrap">
<div class="Grid">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment