Hero Slider Codepen | PROVEN — BUNDLE |
.arrow-right right: 1.5rem;
.btn-primary:hover background: #f0f0f0; transform: translateY(-3px); box-shadow: 0 14px 26px rgba(0,0,0,0.25);
.hero-content h1 font-size: clamp(2.2rem, 7vw, 3.8rem); font-weight: 800; line-height: 1.2; color: #ffffff; text-shadow: 0 2px 12px rgba(0,0,0,0.3); margin-bottom: 1rem; hero slider codepen
<script> (function() // ---------- DOM elements ---------- const track = document.getElementById('slidesTrack'); const slides = Array.from(document.querySelectorAll('.slide')); const prevBtn = document.getElementById('prevBtn'); const nextBtn = document.getElementById('nextBtn'); const dotsContainer = document.getElementById('dotsContainer'); const progressFill = document.getElementById('progressFill');
// restart timer after manual interaction (reset countdown) function restartAutoRotation() if (autoInterval) stopAutoRotation(); startAutoRotation(); .arrow-right right: 1.5rem
// reset progress bar animation (visual + internal timer) function resetProgressBar() if (progressInterval) clearInterval(progressInterval); progressPercent = 0; if (progressFill) progressFill.style.width = '0%'; // start fresh progress interval that increments every 60ms for smooth fill (6 seconds = 6000ms) const stepTime = 60; // ms const totalSteps = autoDelay / stepTime; // 6000/60 = 100 steps let stepCount = 0; progressInterval = setInterval(() => if (isTransitioning) return; // pause increments if transitioning (but not critical) stepCount++; progressPercent = (stepCount / totalSteps) * 100; if (progressFill) progressFill.style.width = `$Math.min(progressPercent, 100)%`; if (stepCount >= totalSteps) // progress completed, auto slide will trigger via main timer // but we don't clear here because timer handles next slide. // We'll stop interval when resetProgressBar called again. , stepTime);
.btn-primary background: #ffffff; color: #0a0c10; box-shadow: 0 8px 18px rgba(0,0,0,0.2); .btn-primary:hover background: #f0f0f0
/* navigation arrows */ .slider-arrow position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; background: rgba(20, 20, 30, 0.7); backdrop-filter: blur(8px); border-radius: 60px; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 20; transition: all 0.2s; border: 1px solid rgba(255,255,255,0.25); color: white; font-size: 1.5rem;
/* slides track */ .slides-track display: flex; transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94); will-change: transform;