photo-galleries
intermediate
grid
gallery
filter
categories
photos
Category · Photo Galleries Difficulty Level · Intermediate Published on · January 28, 2024

Grid Photo Gallery

Clean grid-based photo gallery with filter categories and smooth animations, ideal for organized photo collections.

#grid #gallery #filter #categories #photos

Responsive Design

Yes

Dark Mode Support

No

lines

352

Browser Compatibility

Chrome · Firefox · Safari · Edge

Live Preview

Interact with the component without leaving the page.

450px

Overview

Clean grid-based photo gallery with filter categories and smooth animations, ideal for organized photo collections.

How to use

  1. Copy the HTML markup into your page.
  2. Paste the CSS into your stylesheet and ensure the selectors match your markup.
  3. Paste the JavaScript and load it after the markup.
  4. Adjust spacing, colors, and text to match your design system.

Customization tips

  • Rename class names to avoid collisions with your existing CSS.
  • Replace hard-coded colors with CSS variables for theming.
  • Verify the layout at 320px, 768px, and 1024px widths.

HTML

58

lines

CSS

181

lines

JavaScript

113

lines


                <div class="grid-gallery-container">
  <div class="filter-tabs">
    <button class="filter-btn active" data-filter="all">All</button>
    <button class="filter-btn" data-filter="nature">Nature</button>
    <button class="filter-btn" data-filter="city">City</button>
    <button class="filter-btn" data-filter="people">People</button>
  </div>
  
  <div class="grid-gallery">
    <div class="grid-item" data-category="nature">
      <img src="https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=300&h=300&fit=crop" alt="Mountain" />
      <div class="item-overlay">
        <h4>Mountain Peak</h4>
        <span class="category-tag">Nature</span>
      </div>
    </div>
    
    <div class="grid-item" data-category="city">
      <img src="https://images.unsplash.com/photo-1449824913935-59a10b8d2000?w=300&h=300&fit=crop" alt="City" />
      <div class="item-overlay">
        <h4>Urban Lights</h4>
        <span class="category-tag">City</span>
      </div>
    </div>
    
    <div class="grid-item" data-category="people">
      <img src="https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=300&h=300&fit=crop" alt="Portrait" />
      <div class="item-overlay">
        <h4>Portrait</h4>
        <span class="category-tag">People</span>
      </div>
    </div>
    
    <div class="grid-item" data-category="nature">
      <img src="https://images.unsplash.com/photo-1441974231531-c6227db76b6e?w=300&h=300&fit=crop" alt="Forest" />
      <div class="item-overlay">
        <h4>Forest Path</h4>
        <span class="category-tag">Nature</span>
      </div>
    </div>
    
    <div class="grid-item" data-category="city">
      <img src="https://images.unsplash.com/photo-1480714378408-67cf0d13bc1f?w=300&h=300&fit=crop" alt="Architecture" />
      <div class="item-overlay">
        <h4>Architecture</h4>
        <span class="category-tag">City</span>
      </div>
    </div>
    
    <div class="grid-item" data-category="people">
      <img src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?w=300&h=300&fit=crop" alt="Team" />
      <div class="item-overlay">
        <h4>Team Work</h4>
        <span class="category-tag">People</span>
      </div>
    </div>
  </div>
</div>

              
58lines
2219characters
HTMLLanguage

Browser Compatibility

Chrome

>= 50

Firefox

>= 45

Safari

>= 10

Edge

>= 15

Related Code Snippets

Explore template packs

Need larger building blocks? Browse responsive landing pages and component bundles.

Open HTML Template Library ->