Lay out cards in a neat grid.
What to build
A three-column grid.
Requirements
.gridis a grid container.- It has 3 equal columns, using
repeatandfr. - It has a
gapof16px.
Constraints
Do not use % for the columns.
Example
grid-template-columns: repeat(2, 1fr);
Why it works
fr shares the free space after the gaps are taken out, so that the columns always fit exactly.
Hints
Hint 1
repeat(3, 1fr) means three equal shares.
Solution
Show one correct solution (try it yourself first)
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Grid</title>
<style>
.grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
}
</style>
</head>
<body>
<div class="grid">
<div>One</div><div>Two</div><div>Three</div>
<div>Four</div><div>Five</div><div>Six</div>
</div>
</body>
</html>