Skip to content

Instantly share code, notes, and snippets.

@peter-nikitin
Created September 23, 2017 11:12
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 peter-nikitin/fcfd21f3faec280b8f2a593cfa365720 to your computer and use it in GitHub Desktop.
Save peter-nikitin/fcfd21f3faec280b8f2a593cfa365720 to your computer and use it in GitHub Desktop.
Grid for all browsers
body {
text-align: center;
}
.grid {
display: inline-block;
}
.grid__item {
width: 20em;
display: inline-block;
vertical-align: top;
margin: 1em 0.5em;
text-align: left;
}
@supports (display:flex) {
.grid {
display: flex;
flex-wrap: wrap;
margin: -1em 0 1em -0.5em;
justify-content: space-around;
}
.grid__item {
padding: 1em 0 0 0.5em;
flex: 1 0 20em;
max-width: 20em;
width: auto;
margin: initial;
}
}
@supports (display:grid) {
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(20em, 1fr));
grid-gap: 0.5em;
margin: initial;
}
.grid__item {
padding: initial;
max-width: none;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment