style.css
setup.css
index.html
section {
--columns: 4;
display: grid;
grid-template-columns: repeat(var(--columns), 1fr);
}
@media (min-width: 400px) {
section { --columns: 6; }
}
@media (min-width: 600px) {
section { --columns: 8; }
}
body {
font-family: sans-serif;
padding: 20px;
}
section {
background-color: gold;
}
div {
background-color: tomato;
border-bottom: 2px solid firebrick;
border-right: 2px solid firebrick;
padding: 5px;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/assets/styles/reset.css" rel="stylesheet">
<link href="setup.css" rel="stylesheet">
<link href="style.css" rel="stylesheet">
</head>
<body>
<section>
<div>
<p>Item 1</p>
</div>
<div>
<p>Item 2 <br>with line <br>breaks</p>
</div>
<div>
<p>Item 3 <br>also</p>
</div>
<div>
<p>Item 4</p>
</div>
<div>
<p>Item 5</p>
</div>
<div>
<p>Item 6</p>
</div>
<div>
<p>Item 7 with more text</p>
</div>
<div>
<p>Item 8</p>
</div>
<div>
<p>Item 9 longer</p>
</div>
<div>
<p>Item 10</p>
</div>
<div>
<p>Item 11</p>
</div>
</section>
</body>
</html>