Modern Interactive Parallax Slider
Preview
Edit
Download
Run
Download Options
HTML File
Download as .html file
CSS File
Download as .css file
JavaScript File
Download as .js file
Combined HTML
All code in one HTML file
Project ZIP
All files in a ZIP archive
Cancel
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Modern Interactive Parallax Slider</title> <!-- Google Font: 'Outfit' - Very popular in modern SaaS and dynamic websites --> <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap" rel="stylesheet"> </head> <body> <div class="slider-container"> <!-- Moving Track --> <div class="slider-track" id="track"> <!-- Slide 1: Beach Experience --> <div class="slide active"> <div class="slide-bg-wrapper"> <img src="https://images.unsplash.com/photo-1499793983690-e29da59ef1c2?q=80&w=2000&auto=format&fit=crop" class="slide-bg" alt="Beach"> </div> <div class="overlay"></div> <div class="content"> <div class="category">Tropical Escape</div> <h1 class="title">Island<br>Paradise</h1> <p class="description">Feel the white sand beneath your toes and swim in crystal-clear turquoise waters. Reconnect with nature's rhythm.</p> <a href="#" class="btn"> Explore Beaches <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M12 5l7 7-7 7"/></svg> </a> </div> </div> <!-- Slide 2: Mountain Experience --> <div class="slide"> <div class="slide-bg-wrapper"> <img src="https://images.unsplash.com/photo-1464822759023-fed622ff2c3b?q=80&w=2000&auto=format&fit=crop" class="slide-bg" alt="Mountains"> </div> <div class="overlay"></div> <div class="content"> <div class="category">Alpine Adventure</div> <h1 class="title">Majestic<br>Peaks</h1> <p class="description">Breathe the crisp mountain air. Trek through sweeping valleys and conquer the world's most breathtaking summits.</p> <a href="#" class="btn"> View Expeditions <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M12 5l7 7-7 7"/></svg> </a> </div> </div> <!-- Slide 3: City Experience --> <div class="slide"> <div class="slide-bg-wrapper"> <img src="https://images.unsplash.com/photo-1449824913935-59a10b8d2000?q=80&w=2000&auto=format&fit=crop" class="slide-bg" alt="City"> </div> <div class="overlay"></div> <div class="content"> <div class="category">Urban Life</div> <h1 class="title">Neon<br>Nights</h1> <p class="description">Immerse yourself in the vibrant energy of the metropolis. Discover hidden alleyways, soaring skylines, and endless culture.</p> <a href="#" class="btn"> City Tours <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M5 12h14M12 5l7 7-7 7"/></svg> </a> </div> </div> </div> <!-- UI Controls (Bottom) --> <div class="ui-controls"> <div class="progress-wrapper"> <div class="slide-numbers" id="slideNumber">01 <span>/ 03</span></div> <div class="progress-bar"> <div class="progress-fill" id="progressFill"></div> </div> </div> <div class="arrows"> <button class="arrow-btn" id="prevBtn"> <svg viewBox="0 0 24 24"><path d="M15 19l-7-7 7-7" stroke-linecap="round" stroke-linejoin="round"/></svg> </button> <button class="arrow-btn" id="nextBtn"> <svg viewBox="0 0 24 24"><path d="M9 5l7 7-7 7" stroke-linecap="round" stroke-linejoin="round"/></svg> </button> </div> </div> </div> </body> </html>
CSS
:root { --transition-speed: 1.2s; --easing: cubic-bezier(0.25, 1, 0.5, 1); /* Swift start, smooth slow down */ } * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Outfit', sans-serif; background-color: #0f0f0f; overflow: hidden; } /* Slider Wrapper */ .slider-container { position: relative; width: 100vw; height: 100vh; } /* The Moving Track */ .slider-track { display: flex; width: 300vw; /* 3 slides = 300% */ height: 100%; transition: transform var(--transition-speed) var(--easing); } /* Individual Slide Container */ .slide { position: relative; width: 100vw; height: 100vh; overflow: hidden; display: flex; align-items: center; } /* * PARALLAX MAGIC * Images are wrapped and scaled. When inactive, they are pushed slightly to the side. */ .slide-bg-wrapper { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; } .slide-bg { width: 100%; height: 100%; object-fit: cover; transform: scale(1.1) translateX(10%); /* Starting position for parallax */ transition: transform var(--transition-speed) var(--easing); } /* Active slide image settles perfectly in center */ .slide.active .slide-bg { transform: scale(1) translateX(0); } /* Dynamic Overlay */ .overlay { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.3) 50%, transparent 100%), linear-gradient(0deg, rgba(0,0,0,0.4) 0%, transparent 40%); z-index: 2; } /* Text Content */ .content { position: relative; z-index: 3; max-width: 800px; padding: 0 10%; color: #fff; } .category { display: inline-block; padding: 6px 16px; background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(10px); border-radius: 30px; font-size: 14px; font-weight: 600; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 24px; } .title { font-size: 5.5rem; font-weight: 700; line-height: 1.1; margin-bottom: 20px; text-transform: capitalize; } .description { font-size: 1.2rem; font-weight: 300; line-height: 1.6; color: #e2e8f0; margin-bottom: 40px; max-width: 500px; } /* Glassmorphism CTA Button */ .btn { display: inline-flex; align-items: center; gap: 10px; padding: 16px 32px; background: rgba(255, 255, 255, 0.95); color: #0f0f0f; font-weight: 600; text-decoration: none; border-radius: 8px; transition: all 0.3s ease; } .btn:hover { background: #fff; transform: translateY(-3px); box-shadow: 0 10px 20px rgba(255, 255, 255, 0.2); } /* Text Animation Sequence */ .category, .title, .description, .btn { opacity: 0; transform: translateY(40px); transition: opacity 0.8s ease, transform 0.8s ease; } .slide.active .category { transition-delay: 0.4s; opacity: 1; transform: translateY(0); } .slide.active .title { transition-delay: 0.6s; opacity: 1; transform: translateY(0); } .slide.active .description { transition-delay: 0.8s; opacity: 1; transform: translateY(0); } .slide.active .btn { transition-delay: 1.0s; opacity: 1; transform: translateY(0); } /* UI Controls (Progress & Arrows) */ .ui-controls { position: absolute; bottom: 50px; left: 10%; right: 10%; display: flex; align-items: center; justify-content: space-between; z-index: 10; } /* Modern Progress Bar */ .progress-wrapper { display: flex; align-items: center; gap: 20px; width: 40%; } .slide-numbers { color: #fff; font-weight: 600; font-size: 18px; min-width: 60px; } .slide-numbers span { color: rgba(255,255,255,0.4); font-weight: 400; } .progress-bar { width: 100%; height: 3px; background: rgba(255, 255, 255, 0.2); border-radius: 2px; position: relative; overflow: hidden; } .progress-fill { position: absolute; top: 0; left: 0; height: 100%; background: #fff; width: 33.33%; /* Default for 1st slide */ transition: width 0.8s var(--easing); } /* Navigation Arrows */ .arrows { display: flex; gap: 15px; } .arrow-btn { width: 50px; height: 50px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.3); background: transparent; color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.3s ease; backdrop-filter: blur(5px); } .arrow-btn:hover { background: #fff; border-color: #fff; color: #000; } .arrow-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; } /* Responsive Design */ @media (max-width: 768px) { .title { font-size: 3.5rem; } .progress-wrapper { width: 50%; } .ui-controls { bottom: 30px; } } @media (max-width: 480px) { .title { font-size: 2.8rem; } .ui-controls { flex-direction: column-reverse; align-items: flex-start; gap: 20px; } .progress-wrapper { width: 100%; } }
JavaScript
document.addEventListener('DOMContentLoaded', () => { const track = document.getElementById('track'); const slides = document.querySelectorAll('.slide'); const progressFill = document.getElementById('progressFill'); const slideNumber = document.getElementById('slideNumber'); const prevBtn = document.getElementById('prevBtn'); const nextBtn = document.getElementById('nextBtn'); let currentIndex = 0; const totalSlides = slides.length; function updateSlider() { // 1. Move the Track track.style.transform = `translateX(-${currentIndex * 100}vw)`; // 2. Manage Active Class (triggers Parallax & Text animation) slides.forEach((slide, index) => { if(index === currentIndex) { slide.classList.add('active'); } else { slide.classList.remove('active'); } }); // 3. Update Progress Bar const progressPercentage = ((currentIndex + 1) / totalSlides) * 100; progressFill.style.width = `${progressPercentage}%`; // 4. Update Numbers (e.g., 01 / 03) slideNumber.innerHTML = `0${currentIndex + 1} <span>/ 0${totalSlides}</span>`; } nextBtn.addEventListener('click', () => { currentIndex = (currentIndex + 1) % totalSlides; // Loops back to 0 updateSlider(); }); prevBtn.addEventListener('click', () => { currentIndex = (currentIndex - 1 + totalSlides) % totalSlides; // Loops back to end updateSlider(); }); // Optional: Auto-play every 6 seconds /* setInterval(() => { nextBtn.click(); }, 6000); */ });
Output Preview
Desktop
Mobile
Fullscreen