Upcoming

How to Make Clickable Image Banner Slider in Elementor

Tools and Links Used

Hostinger Fast, beginner friendly WordPress hosting.
Get Hosting
Elementor The free page builder this tutorial is built with.
Get Elementor
Elementor Pro The Pro upgrade used throughout this tutorial.
Get Elementor Pro
Project Files Download the resources used in this tutorial.
Download Files
Kitpapa Ready made Elementor template kits.
Get Templates
Kitninja eCommerce Elementor template kits.
Get Templates

Prompt Used in This Tutorial

Clickable Image Banner Slider in Elementor Style CSS
<style>

body {
      overflow-x: hidden;
    }
    .thumbnail figure.wp-caption {
    height: 100%;
}

    /* Hero Two Section */
    .hero-two {
      position: relative;
      width: 100%;
      height: 100vh;
    }

    .hero-two__area {
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: end;
      width: 100%;
      height: 100%;
    }

    /* Background Images */
    .hero-two__background {
      position: absolute;
      content: "";
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 1;
    }

    .hero-two__background .background-img {
      position: absolute;
      content: "";
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      opacity: 0;
    }

    .hero-two__background .background-img img {
      width: 100%;
      height: 100%;
      object-fit: cover;
    }

    /* Hero Content */
    .hero-two__content {
      position: relative;
      display: flex;
      justify-content: space-between;
      align-items: center;
      z-index: 10;
      padding: 60px 80px;
      width: 100%;
      height: calc(100% - 140px);
    }



    .hero-two__content .left-content .hero-text {
      font-size: 20px;
      line-height: 1.6;
      margin-bottom: 40px;
      opacity: 0.74;
    }

    .hero-two__content .left-content .info {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 20px;
    }

    .hero-two__content .left-content .info .copyright {
      font-size: 14px;
      opacity: 0.6;
      display: inline-flex;
      align-items: center;
    }

    .hero-two__content .right-content .site-links ul,
    .hero-two__content .right-content .social-links ul {
      list-style: none;
      padding: 0;
      margin: 0;
    }

    .hero-two__content .right-content .site-links ul li,
    .hero-two__content .right-content .social-links ul li {
      margin-bottom: 15px;
    }

    .hero-two__content .right-content .site-links ul li a,
    .hero-two__content .right-content .social-links ul li a {
      position: relative;
      color: var(--color-2);
      font-size: 18px;
      text-decoration: none;
      transition: opacity 0.3s;
    }

    .hero-two__content .right-content .site-links ul li span,
    .hero-two__content .right-content .social-links ul li span {
      display: inline-flex;
      align-items: center;
      gap: 8px;
    }

    .hero-two__content .right-content .site-links ul li span::before,
    .hero-two__content .right-content .social-links ul li span::before {
      content: "→";
      font-size: 14px;
    }

    .hero-two__content .right-content .site-links ul li a:hover,
    .hero-two__content .right-content .social-links ul li a:hover {
      opacity: 0.6;
    }

    /* Gallery */
    .hero-two__gallery {
      position: relative;
      display: flex;
      justify-content: center;
      align-items: flex-end;
      width: 100%;
      height: 140px;
      z-index: 20;
      gap: 12px;
    }

    .hero-two__gallery .thumbnail {
      position: relative;
      width: 140px;
      height: 140px;
      overflow: hidden;
      cursor: pointer;
      flex-shrink: 0;
      align-self: flex-end;
      transform-origin: bottom center;
    }

    .hero-two__gallery .thumbnail img {
      position: relative;
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
    }
    
    .hero-two__gallery .thumbnail {
    cursor: pointer;
    will-change: width, height;
    border-radius: 4px;
    overflow: hidden;
    transition: unset;
}

    .hero-two__gallery .thumbnail .widget-image-caption {
      position: absolute;
      bottom: 15px;
      left: 15px;
      color: var(--color-white);
      font-size: 14px;
      font-weight: 500;
      opacity: 0;
      transition: opacity 0.3s ease;
      z-index: 2;
      background: rgba(0, 0, 0, 0.5);
      padding: 6px 12px;
      border-radius: 4px;
      pointer-events: none;
    }

    .hero-two__gallery .thumbnail.hovered .widget-image-caption {
      opacity: 1;
    }

@media (max-width: 1500px) {
  .thumbnail-wrapper {
    width: 1200px;
  }
}

@media (max-width: 1260px) {
  .thumbnail-wrapper {
    width: 900px;
  }
}

  @media (max-width: 767.98px) {
    .hero-two__gallery {
      overflow: hidden !important;
      padding: 20px 0;
    }
    
    .marquee-track {
      display: flex !important;
      gap: 16px;
      will-change: transform;
    }
    
    .marquee-track > .thumbnail {
      flex-shrink: 0 !important;
      cursor: pointer;
      transition: all 0.3s ease;
    }
    
    .marquee-track .thumbnail.active {
      transform: scale(1.1);
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
      z-index: 10;
    }
  }

  </style>
Clickable Image Banner Slider in Elementor Style CSS Classes
thumbnail
hero-two
hero-two__area
hero-two__background
background-img
hero-two__content
left-content
hero-text
info
copyright
right-content
site-links
social-links
hero-two__gallery
thumbnail
Clickable Image Banner Slider in Elementor JS Code
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js"></script>

<script>
  const heroTwoAnimation = () => {
    const galleryContainer = document.querySelector(".hero-two__gallery");
    const headerSection = document.querySelector(".hero-two__content");
    const thumbnails = document.querySelectorAll(".hero-two__gallery > .thumbnail");
    const backgroundImages = document.querySelectorAll(".background-img");
    
    if (!galleryContainer || !thumbnails.length) return;
    
    thumbnails.forEach((thumbnail, index) => {
      thumbnail.setAttribute('data-index', index);
    });
    
    if (window.innerWidth < 1200) {
      const track = document.createElement('div');
      track.className = 'marquee-track';
      
      const originalThumbs = Array.from(thumbnails);
      originalThumbs.forEach(thumb => track.appendChild(thumb));
      
      for (let i = 0; i < 3; i++) {
        originalThumbs.forEach(thumb => {
          const clone = thumb.cloneNode(true);
          clone.setAttribute('data-index', thumb.getAttribute('data-index'));
          track.appendChild(clone);
        });
      }
      
      galleryContainer.appendChild(track);
      
      const allThumbs = track.querySelectorAll('.thumbnail');
      
      let setWidth = 0;
      originalThumbs.forEach(thumb => {
        setWidth += thumb.offsetWidth + 16;
      });
      
      let currentX = 0;
      const speed = 1;
      
      const animate = () => {
        currentX -= speed;
        if (Math.abs(currentX) >= setWidth) {
          currentX = 0;
        }
        gsap.set(track, { x: currentX });
        requestAnimationFrame(animate);
      };
      
      animate();
      
      let isPaused = false;
      
      allThumbs.forEach((thumbnail) => {
        thumbnail.addEventListener("click", (e) => {
          const clickedIndex = parseInt(e.currentTarget.getAttribute('data-index'), 10);
          if (isNaN(clickedIndex)) return;
          
          isPaused = true;
          
          if (headerSection) {
            gsap.to(headerSection, { 
              opacity: 0, 
              duration: 0.4,
              ease: "power1.inOut"
            });
          }
          
          if (backgroundImages.length) {
            backgroundImages.forEach((bg, index) => {
              gsap.to(bg, {
                opacity: index === clickedIndex ? 1 : 0,
                duration: 0.4,
                ease: "power1.inOut"
              });
            });
          }
          
          allThumbs.forEach((thumb) => thumb.classList.remove("active"));
          e.currentTarget.classList.add("active");
        });
      });
      
      document.addEventListener("click", (e) => {
        if (!e.target.closest(".hero-two__gallery") && !e.target.closest(".background-img")) {
          isPaused = false;
          
          if (headerSection) {
            gsap.to(headerSection, { 
              opacity: 1, 
              duration: 0.4,
              ease: "power1.inOut"
            });
          }
          
          if (backgroundImages.length) {
            gsap.to(backgroundImages, { 
              opacity: 0, 
              duration: 0.4,
              ease: "power1.inOut"
            });
          }
          
          allThumbs.forEach((thumb) => thumb.classList.remove("active"));
        }
      });
      
      const animateWithPause = () => {
        if (!isPaused) {
          currentX -= speed;
          if (Math.abs(currentX) >= setWidth) {
            currentX = 0;
          }
        }
        gsap.set(track, { x: currentX });
        requestAnimationFrame(animateWithPause);
      };
      
      requestAnimationFrame(animateWithPause);
    }
    
    if (window.innerWidth >= 1200) {
      let initialSize;
      let currentSizeMap = [];
      
      if (headerSection && backgroundImages.length) {
        const baseSizeMap = [
          [220, 200, 180, 160, 140, 120, 100, 90, 80, 75],
          [180, 220, 180, 160, 140, 120, 110, 100, 90, 80],
          [160, 180, 220, 180, 160, 140, 120, 110, 100, 80],
          [140, 160, 180, 220, 180, 160, 140, 120, 100, 100],
          [120, 140, 160, 180, 220, 180, 160, 140, 120, 100],
          [100, 120, 140, 160, 180, 220, 180, 160, 140, 120],
          [100, 100, 110, 120, 140, 180, 220, 180, 160, 140],
          [80, 90, 100, 120, 140, 160, 180, 220, 180, 160],
          [60, 70, 80, 100, 120, 140, 160, 180, 220, 180],
          [75, 80, 90, 100, 110, 120, 140, 160, 180, 220],
        ];

        const setupSizes = () => {
          const screenWidth = window.innerWidth;
          if (screenWidth >= 1800) {
            const galleryContainerWidth = galleryContainer.offsetWidth;
            initialSize = galleryContainerWidth / thumbnails.length;
          } else if (screenWidth >= 1200) {
            initialSize = 110;
          }
          
          const scale = initialSize / 140;
          currentSizeMap = baseSizeMap.map((row) =>
            row.map((size) => size * scale)
          );
          
          gsap.set(thumbnails, { width: initialSize, height: initialSize });
        };
        
        setupSizes();
        window.addEventListener("resize", setupSizes);

        const handleMouseOver = (e) => {
          const hoveredIndex = parseInt(e.currentTarget.dataset.index, 10);
          
          gsap.to(headerSection, { 
            opacity: 0, 
            duration: 0.4,
            ease: "power1.inOut"
          });
          
          backgroundImages.forEach((bg, index) => {
            gsap.to(bg, {
              opacity: index === hoveredIndex ? 1 : 0,
              duration: 0.4,
              ease: "power1.inOut"
            });
          });
          
          thumbnails.forEach((thumb) => thumb.classList.remove("hovered"));
          e.currentTarget.classList.add("hovered");
          
          const currentHoverMap = currentSizeMap[hoveredIndex];
          if (!currentHoverMap) return;
          
          thumbnails.forEach((thumb, index) => {
            const size = currentHoverMap[index] || initialSize;
            gsap.to(thumb, { 
              width: size, 
              height: size, 
              duration: 0.3,
              ease: "power2.out"
            });
          });
        };

        const handleMouseLeave = () => {
          gsap.to(headerSection, { 
            opacity: 1, 
            duration: 0.4,
            ease: "power1.inOut"
          });
          
          gsap.to(backgroundImages, { 
            opacity: 0, 
            duration: 0.4,
            ease: "power1.inOut"
          });
          
          gsap.to(thumbnails, {
            width: initialSize,
            height: initialSize,
            duration: 0.3,
            ease: "power2.out"
          });
          
          thumbnails.forEach((thumb) => thumb.classList.remove("hovered"));
        };

        thumbnails.forEach((thumbnail) => {
          thumbnail.addEventListener("mouseover", handleMouseOver);
        });
        
        galleryContainer.addEventListener("mouseleave", handleMouseLeave);
      }
    }
  };
  
  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', heroTwoAnimation);
  } else {
    heroTwoAnimation();
  }
</script>

Get Your FREE Freelancing Roadmap

Stop hopping between tutorials. Grab the Freelancing Mastery Handbook to learn how to choose a skill, build your foundation, find clients, and confidently start your freelancing journey.

Free eBook Download

Related Tutorials

From learning the right skills to building a stronger digital presence, we help you turn ideas into practical, professional results.

Vibe Code a REAL Animated WordPress Website with Claude + Elementor

21.8K views

View Tutorial

Vibe Coding Full Course for Beginners – Build & Launch a Real SaaS

3.3K views

View Tutorial

Edit Videos with ChatGPT Codex — Raw Clips to Finished Reel

3.4K views

View Tutorial

Browse All Tutorials