Gallery Grid

GalleryGrid creates a gallery with CSS Grid. You can use auto-fill or auto-fit to size the columns.


Create Galleries easily with CSS Grid

GalleryGrid lets you create a Gallery with CSS grid. It uses auto-fill by default.

index.html
<div class="GalleryGrid">
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
</div>
Resize to see this work!

Choose from auto-fill or auto-fit

You can change to auto-fit easily by using the Gallery-fit class. This makes each column expand to fill the available space.

index.html
<div class="GalleryGrid-fit">
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
</div>
Resize to see this work!

Change the width of each column

You can size each column with --item-width.

index.html
<div class="GalleryGrid [--item-width:5rem]">
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
</div>
Resize to see this work!

Never worry about grid items exceeding their container

All grid items have a max-width of 100%, so you can set --item-width to your heart’s content without worrying about it being too large.

index.html
<div class="GalleryGrid [--item-width:200px]">
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
</div>
Resize to see this work!