Last active
June 10, 2019 19:22
-
-
Save csandman/e57e27b8ba018670bbcbc6744f324540 to your computer and use it in GitHub Desktop.
Grid with flex-wrap, a single container, and a variable gap value
This file contains 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
$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