An interactive, grid-based visual effect built with pure HTML, CSS, and JavaScript. As the user hovers over the viewport, dynamically generated tiles expand and reveal portions of a fixed background image with smooth fade transitions, creating a dynamic reveal and ripple impression.
- Interactive mouse-driven hover animation
- Dynamic DOM generation creating an immersive full-screen tile grid
- Fixed background attachment giving a seamless reveal across separate grid elements
- Instant hover response with gradual fade-out transition
- Zero dependencies or external libraries
- Runs directly in any modern web browser
Background-Animation-Project-HTML-CSS-JAVASCRIPT-/
├── index.html
├── style.css
└── index.js
- Grid Generation (
index.js): A simple JavaScript loop instantiates 2,000<span>elements and appends them into the.containerwrapper. - Fixed Background Illusion (
style.css): Each<span>has a::beforepseudo-element referencing an image withbackground-attachment: fixed. Because the background is locked to the viewport, all tiles reveal coherent parts of the same image. - Transition Dynamics:
- Default State: Pseudo-elements have an opacity of
0and a long20stransition, creating a slow fade-out trail when cursor leaves. - Hover State (
:hover::before): Transition resets to0s, opacity snaps to1, and tile dimensions expand instantly to reveal the image under the cursor.
- Default State: Pseudo-elements have an opacity of
No build steps, installations, or local servers are required.
git clone https://github.com/Kumar44developer/Background-Animation-Project-HTML-CSS-JAVASCRIPT-.gitOpen index.html directly in your web browser, or launch it with any local server extension (such as VS Code Live Server).
- Change Background Image: Update the image URL inside
style.csson line 29:background: url(YOUR_IMAGE_URL_HERE);
- Adjust Grid Density: Modify the loop counter in
index.jsto increase or decrease tile density:for(let i = 1; i < 2000; i++)
- Change Trail Duration: Alter the default
transitionduration in.container span::beforeinstyle.cssto lengthen or shorten the fade-out effect.
Kumar44developer — GitHub Profile
