DEV Community

Cover image for Interactive Hover Showcase
Pawar Shivam
Pawar Shivam

Posted on

Interactive Hover Showcase

Interactive Fullscreen Hover Tab Gallery (Pure CSS + JS)

πŸš€ Introduction

In this project, I created a fullscreen hover tab gallery effect using pure CSS and JavaScript.

🎯 Features

  • Smooth background transition
  • Hover based tab switching
  • Fully responsive layout
  • No external library required

πŸ› οΈ How It Works

Each column has a data-tab attribute.
On hover, JavaScript activates the corresponding background image.

πŸ’» JavaScript Logic

πŸ”— Live Demo


js
const tabs = document.querySelectorAll(".cluom-box");

tabs.forEach((tab) => {
  tab.addEventListener("mouseover", function () {
    tabs.forEach((e) => e.classList.remove("current"));
    this.classList.add("current");

    const tabId = this.getAttribute("data-tab");

    document
      .querySelectorAll(".bg-img")
      .forEach((img) => img.classList.remove("current"));

    document.getElementById(tabId).classList.add("current");
  });
});
Enter fullscreen mode Exit fullscreen mode

Top comments (0)