<div class="wrapper">
<ul class="auto-grid">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
<li>Item 6</li>
<li>Item 7</li>
<li>Item 8</li>
<li>Item 9</li>
<li>Item 10</li>
<li>Item 11</li>
<li>Item 12</li>
</ul>
</div>
/*
AUTO GRID
Set the minimum item size with `--auto-grid-min-size` and you'll
get a fully responsive grid with no media queries.
*/
.auto-grid {
--auto-grid-min-size: 16rem;
}
.auto-grid > * {
max-width: 400px;
}
.auto-grid > * + * {
margin-top: 1rem;
}
@supports(display: grid) {
.auto-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(var(--auto-grid-min-size), 1fr));
grid-gap: 1rem;
}
.auto-grid > * {
max-width: unset;
}
.auto-grid > * + * {
margin-top: unset;
}
}
/*
WRAPPER
A utility with a max width that contains child elements and horizontal centers them
*/
.wrapper {
max-width: 65rem;
margin: 0 auto;
padding: 0 1rem;
}
/* Presentational styles */
body {
background: #efefef;
padding: 1rem 0;
line-height: 1.4;
font-family: sans-serif;
}
li {
padding: 5rem 1rem;
text-align: center;
font-size: 1.2rem;
background: #22a6b3;
color: #ffffff;
}
This Pen doesn't use any external JavaScript resources.