Galería de Imágenes

Intermedio

Galería de imágenes moderna con diseño de cuadrícula, efecto lightbox, filtrado y diseño responsivo.

Vista Previa en Vivo

Implementación del Código

HTML
<div class="gallery-container">
  <div class="gallery-header">
    <h1 class="gallery-title">Galería de Fotos</h1>
    <p class="gallery-subtitle">Explora nuestra colección de fotografías impresionantes</p>
  </div>
  
  <!-- Botones de Filtro -->
  <div class="filter-controls">
    <button class="filter-btn active" data-filter="all">Todas</button>
    <button class="filter-btn" data-filter="nature">Naturaleza</button>
    <button class="filter-btn" data-filter="architecture">Arquitectura</button>
    <button class="filter-btn" data-filter="portrait">Retrato</button>
    <button class="filter-btn" data-filter="street">Urbana</button>
  </div>
  
  <!-- Cuadrícula de Galería -->
  <div class="gallery-grid" id="galleryGrid">
    <div class="gallery-item" data-category="nature">
      <img src="https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=400&h=300&fit=crop" alt="Paisaje montañoso" loading="lazy">
      <div class="gallery-overlay">
        <div class="gallery-info">
          <h3 class="gallery-item-title">Vista de Montaña</h3>
          <p class="gallery-item-category">Naturaleza</p>
        </div>
        <button class="gallery-zoom-btn" data-index="0">
          <svg viewBox="0 0 24 24" fill="currentColor">
            <path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
            <path d="M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z"/>
          </svg>
        </button>
      </div>
    </div>
    
    <div class="gallery-item" data-category="architecture">
      <img src="https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?w=400&h=300&fit=crop" alt="Edificio moderno" loading="lazy">
      <div class="gallery-overlay">
        <div class="gallery-info">
          <h3 class="gallery-item-title">Arquitectura Urbana</h3>
          <p class="gallery-item-category">Arquitectura</p>
        </div>
        <button class="gallery-zoom-btn" data-index="1">
          <svg viewBox="0 0 24 24" fill="currentColor">
            <path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
            <path d="M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z"/>
          </svg>
        </button>
      </div>
    </div>
    
    <div class="gallery-item" data-category="portrait">
      <img src="https://images.unsplash.com/photo-1494790108755-2616c6d4e6e8?w=400&h=300&fit=crop" alt="Fotografía de retrato" loading="lazy">
      <div class="gallery-overlay">
        <div class="gallery-info">
          <h3 class="gallery-item-title">Estudio de Retrato</h3>
          <p class="gallery-item-category">Retrato</p>
        </div>
        <button class="gallery-zoom-btn" data-index="2">
          <svg viewBox="0 0 24 24" fill="currentColor">
            <path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
            <path d="M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z"/>
          </svg>
        </button>
      </div>
    </div>
    
    <div class="gallery-item" data-category="street">
      <img src="https://images.unsplash.com/photo-1449824913935-59a10b8d2000?w=400&h=300&fit=crop" alt="Fotografía urbana" loading="lazy">
      <div class="gallery-overlay">
        <div class="gallery-info">
          <h3 class="gallery-item-title">Calles de la Ciudad</h3>
          <p class="gallery-item-category">Urbana</p>
        </div>
        <button class="gallery-zoom-btn" data-index="3">
          <svg viewBox="0 0 24 24" fill="currentColor">
            <path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
            <path d="M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z"/>
          </svg>
        </button>
      </div>
    </div>
    
    <div class="gallery-item" data-category="nature">
      <img src="https://images.unsplash.com/photo-1441974231531-c6227db76b6e?w=400&h=300&fit=crop" alt="Sendero del bosque" loading="lazy">
      <div class="gallery-overlay">
        <div class="gallery-info">
          <h3 class="gallery-item-title">Sendero del Bosque</h3>
          <p class="gallery-item-category">Naturaleza</p>
        </div>
        <button class="gallery-zoom-btn" data-index="4">
          <svg viewBox="0 0 24 24" fill="currentColor">
            <path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
            <path d="M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z"/>
          </svg>
        </button>
      </div>
    </div>
    
    <div class="gallery-item" data-category="architecture">
      <img src="https://images.unsplash.com/photo-1518005020951-eccb494ad742?w=400&h=300&fit=crop" alt="Arquitectura moderna" loading="lazy">
      <div class="gallery-overlay">
        <div class="gallery-info">
          <h3 class="gallery-item-title">Estructura de Cristal</h3>
          <p class="gallery-item-category">Arquitectura</p>
        </div>
        <button class="gallery-zoom-btn" data-index="5">
          <svg viewBox="0 0 24 24" fill="currentColor">
            <path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
            <path d="M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z"/>
          </svg>
        </button>
      </div>
    </div>
    
    <div class="gallery-item" data-category="portrait">
      <img src="https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=400&h=300&fit=crop" alt="Retrato" loading="lazy">
      <div class="gallery-overlay">
        <div class="gallery-info">
          <h3 class="gallery-item-title">Estudio de Carácter</h3>
          <p class="gallery-item-category">Retrato</p>
        </div>
        <button class="gallery-zoom-btn" data-index="6">
          <svg viewBox="0 0 24 24" fill="currentColor">
            <path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
            <path d="M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z"/>
          </svg>
        </button>
      </div>
    </div>
    
    <div class="gallery-item" data-category="street">
      <img src="https://images.unsplash.com/photo-1477959858617-67f85cf4f1df?w=400&h=300&fit=crop" alt="Escena urbana" loading="lazy">
      <div class="gallery-overlay">
        <div class="gallery-info">
          <h3 class="gallery-item-title">Vida Urbana</h3>
          <p class="gallery-item-category">Urbana</p>
        </div>
        <button class="gallery-zoom-btn" data-index="7">
          <svg viewBox="0 0 24 24" fill="currentColor">
            <path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
            <path d="M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z"/>
          </svg>
        </button>
      </div>
    </div>
  </div>
  
  <!-- Modal Lightbox -->
  <div class="lightbox" id="lightbox">
    <div class="lightbox-content">
      <button class="lightbox-close" id="lightboxClose">
        <svg viewBox="0 0 24 24" fill="currentColor">
          <path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>
        </svg>
      </button>
      
      <button class="lightbox-nav lightbox-prev" id="lightboxPrev">
        <svg viewBox="0 0 24 24" fill="currentColor">
          <path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/>
        </svg>
      </button>
      
      <button class="lightbox-nav lightbox-next" id="lightboxNext">
        <svg viewBox="0 0 24 24" fill="currentColor">
          <path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/>
        </svg>
      </button>
      
      <div class="lightbox-image-container">
        <img class="lightbox-image" id="lightboxImage" src="" alt="">
      </div>
      
      <div class="lightbox-info">
        <h3 class="lightbox-title" id="lightboxTitle"></h3>
        <p class="lightbox-category" id="lightboxCategory"></p>
        <div class="lightbox-counter">
          <span id="lightboxCounter">1 / 8</span>
        </div>
      </div>
    </div>
  </div>
</div>

Características del Fragmento

Diseño Responsivo: Sí
Soporte para Modo Oscuro: No
Categoría: photo-galleries
Nivel de Dificultad: Intermedio

Compatibilidad del Navegador

🟢
chrome 60+
🟠
firefox 55+
🔵
safari 10+
🟦
edge 15+