Skip to content

Instantly share code, notes, and snippets.

@dfkaye
Created September 19, 2019 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dfkaye/33f760bcc994297e45507f669cbb220a to your computer and use it in GitHub Desktop.
Save dfkaye/33f760bcc994297e45507f669cbb220a to your computer and use it in GitHub Desktop.
Andy Bell's auto grid CSS without media queries
/*
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