Grid Simple Gallery
CSS
Medium
2 views
Problem Description
Create a small image gallery grid with auto-fill columns.
Output Format
Print the HTML+CSS code in one block.
Constraints
Use repeat(auto-fill, minmax(...)) for columns.
Official Solution
<!doctype html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<title>meetcode</title>
<style>
.gallery { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); width: min(92%, 720px); margin: 0 auto; }
.ph { aspect-ratio: 4 / 3; border-radius: 12px; background: #e5e7eb; display: grid; place-items: center; color: #111; }
</style>
</head>
<body>
<div class='gallery'>
<div class='ph'>1</div>
<div class='ph'>2</div>
<div class='ph'>3</div>
<div class='ph'>4</div>
<div class='ph'>5</div>
</div>
</body>
</html>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!