CodShot
CSS Public

Responsive CSS Grid Gallery

A responsive gallery layout using CSS grid and auto-fit.

#css #grid #responsive #gallery
CSS
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.gallery img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 0.75rem;
}

Notes

auto-fit + minmax is a great pattern for responsive cards and galleries.

Snippet actions

CodShot user
CodShot user
Updated: 2026-06-03 14:05
Public snippets
0
Forks
CodShot AI Help
Ask about CodShot features, plans, workspace, AI limits, referrals, and public help topics.
Hi! I can help you understand how CodShot works. What would you like to know?
For account-specific or sensitive issues, please open a support ticket. Open support