Skip to content

Instantly share code, notes, and snippets.

@csandman
Last active June 10, 2019 19:22
Show Gist options
  • Save csandman/e57e27b8ba018670bbcbc6744f324540 to your computer and use it in GitHub Desktop.
Save csandman/e57e27b8ba018670bbcbc6744f324540 to your computer and use it in GitHub Desktop.
Grid with flex-wrap, a single container, and a variable gap value
$gap: 1rem;
.grid {
display: flex;
margin: 0 calc(#{$gap} / -2) -$gap calc(#{$gap} / -2);
flex-wrap: wrap;
}
.item {
flex: 0 0 auto;
margin: 0 calc(#{$gap} / 2) $gap calc(#{$gap} / 2);
width: calc(33.3333% - #{$gap});
}
@media only screen and (max-width: 900px) {
.item {
width: calc(50% - #{$gap});
}
}
@media only screen and (max-width: 650px) {
.item {
width: calc(100% - #{$gap});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment