Created
September 19, 2019 16:51
-
-
Save dfkaye/33f760bcc994297e45507f669cbb220a to your computer and use it in GitHub Desktop.
Andy Bell's auto grid CSS without media queries
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
/* | |
19 Sept 2019 | |
See "Keeping it simple with CSS that scales" | |
at https://hankchizljaw.com/wrote/keeping-it-simple-with-css-that-scales/ | |
*/ | |
.auto-grid { | |
display: grid; | |
grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); | |
grid-gap: 1rem; | |
} | |
.auto-grid > * { | |
max-width: 25rem; | |
margin-left: auto; | |
margin-right: auto; | |
} | |
.auto-grid > * + * { | |
margin-top: 1rem; | |
} | |
@supports (display: grid) { | |
.auto-grid > * { | |
max-width: unset; | |
margin: 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment