Skip to content

Instantly share code, notes, and snippets.

@MariaJackson1
Last active August 8, 2022 20:53
Show Gist options
  • Select an option

  • Save MariaJackson1/c079d644b261aae50ed037264a2e700c to your computer and use it in GitHub Desktop.

Select an option

Save MariaJackson1/c079d644b261aae50ed037264a2e700c to your computer and use it in GitHub Desktop.
CSS Grid Layout for Modern Browsers
/* ------------------------------------------
Basic one-column layout for all browsers
--------------------------------------------*/
.grid-container {
max-width: 50em;
}
.grid-container > * {
text-align: center;
display: flex;
align-items: center;
justify-content: center;
font-size: 2rem;
padding: 1rem;
}
/* ------------------------------------------
CSS Grid layout for modern browsers
--------------------------------------------*/
@supports (display: grid) {
@media (min-width: 50em) {
.grid-container {
display: grid;
margin: auto;
grid-template-columns: repeat(4, 200px);
grid-template-rows: repeat(2, 200px);
grid-gap: 20px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment