Animated Gym Hero Section
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>NexusFit - Futuristic Gym</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> </head> <body> <section class="hero"> <div class="floating-elements"> <div class="floating-element"></div> <div class="floating-element"></div> <div class="floating-element"></div> <div class="floating-element"></div> </div> <div class="hero-image"> <img src="https://cdn-icons-png.flaticon.com/512/2496/2496934.png" alt="Futuristic gym equipment"> </div> <div class="hero-content"> <h1>Elevate Your Training</h1> <p>Experience the future of fitness with our cutting-edge technology, AI-powered workouts, and immersive training environments designed to maximize your potential.</p> <button class="cta-button">Join NexusFit Today <i class="fas fa-arrow-right" style="margin-left: 10px;"></i></button> <div class="stats-container"> <div class="stat-item"> <div class="stat-number" id="members-count">0</div> <div class="stat-label">Active Members</div> </div> <div class="stat-item"> <div class="stat-number">50+</div> <div class="stat-label">Holo-Trainers</div> </div> <div class="stat-item"> <div class="stat-number">24/7</div> <div class="stat-label">AI Coaching</div> </div> <div class="stat-item"> <div class="stat-number">100%</div> <div class="stat-label">Satisfaction</div> </div> </div> </div> </section> <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.4/gsap.min.js"></script> </body> </html>
CSS
:root { --primary: #00f0ff; --secondary: #ff00aa; --dark: #0a0a1a; --light: #f0f0ff; --accent: #7700ff; } * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Orbitron', sans-serif; } body { background-color: var(--dark); color: var(--light); overflow-x: hidden; } @keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-20px); } } @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } } @keyframes glow { 0% { box-shadow: 0 0 10px var(--primary); } 50% { box-shadow: 0 0 30px var(--primary); } 100% { box-shadow: 0 0 10px var(--primary); } } @keyframes scanline { 0% { background-position: 0 0; } 100% { background-position: 0 100vh; } } .hero { position: relative; height: 100vh; display: flex; align-items: center; justify-content: center; overflow: hidden; background: linear-gradient(135deg, var(--dark) 0%, #1a1a2e 100%); } .hero::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient( rgba(0, 240, 255, 0.1) 1px, transparent 1px ); background-size: 100% 4px; animation: scanline 60s linear infinite; pointer-events: none; } .hero-content { position: relative; z-index: 2; text-align: center; padding: 0 20px; max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; } .hero h1 { font-size: clamp(2.5rem, 8vw, 5rem); margin-bottom: 20px; background: linear-gradient(90deg, var(--primary), var(--secondary)); -webkit-background-clip: text; background-clip: text; color: transparent; text-transform: uppercase; letter-spacing: 3px; line-height: 1.2; text-shadow: 0 0 20px rgba(0, 240, 255, 0.3); animation: pulse 3s infinite; } .hero p { font-size: clamp(1rem, 2vw, 1.5rem); margin-bottom: 40px; max-width: 700px; opacity: 0.9; line-height: 1.6; } .cta-button { display: inline-flex; align-items: center; justify-content: center; padding: 15px 40px; background: linear-gradient(45deg, var(--primary), var(--accent)); color: var(--dark); font-weight: bold; text-transform: uppercase; letter-spacing: 2px; border: none; border-radius: 50px; cursor: pointer; transition: all 0.3s ease; position: relative; overflow: hidden; z-index: 1; font-size: 1.1rem; animation: glow 2s infinite; } .cta-button:hover { transform: translateY(-5px); box-shadow: 0 10px 30px rgba(0, 240, 255, 0.5); animation: none; } .cta-button::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(45deg, var(--accent), var(--primary)); z-index: -1; opacity: 0; transition: opacity 0.3s ease; } .cta-button:hover::before { opacity: 1; } .hero-image { position: absolute; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; z-index: 1; opacity: 0.2; } .hero-image img { max-width: 80%; max-height: 80%; object-fit: contain; filter: drop-shadow(0 0 30px var(--primary)); animation: float 6s ease-in-out infinite; } .stats-container { display: flex; justify-content: center; gap: 30px; margin-top: 50px; flex-wrap: wrap; } .stat-item { background: rgba(10, 10, 26, 0.7); border: 1px solid var(--primary); border-radius: 10px; padding: 20px; min-width: 150px; text-align: center; backdrop-filter: blur(5px); transition: transform 0.3s ease; } .stat-item:hover { transform: translateY(-10px) scale(1.05); background: rgba(0, 240, 255, 0.1); } .stat-number { font-size: 2.5rem; font-weight: bold; background: linear-gradient(90deg, var(--primary), var(--light)); -webkit-background-clip: text; background-clip: text; color: transparent; margin-bottom: 5px; } .stat-label { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 2px; opacity: 0.8; } .floating-elements { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; } .floating-element { position: absolute; background: rgba(0, 240, 255, 0.1); border: 1px solid var(--primary); border-radius: 50%; filter: blur(1px); animation: float 10s ease-in-out infinite; } .floating-element:nth-child(1) { width: 30px; height: 30px; top: 20%; left: 10%; animation-delay: 0s; } .floating-element:nth-child(2) { width: 50px; height: 50px; top: 60%; left: 15%; animation-delay: 2s; } .floating-element:nth-child(3) { width: 20px; height: 20px; top: 30%; right: 10%; animation-delay: 4s; } .floating-element:nth-child(4) { width: 40px; height: 40px; top: 70%; right: 15%; animation-delay: 6s; } @media (max-width: 768px) { .stats-container { gap: 15px; } .stat-item { min-width: 120px; padding: 15px 10px; } .stat-number { font-size: 2rem; } } @media (max-width: 480px) { .hero h1 { font-size: 2.5rem; } .stats-container { flex-direction: column; align-items: center; } .stat-item { width: 80%; } }
JavaScript
// Animate the counter function animateCounter(target, start, end, duration) { let startTimestamp = null; const step = (timestamp) => { if (!startTimestamp) startTimestamp = timestamp; const progress = Math.min((timestamp - startTimestamp) / duration, 1); const value = Math.floor(progress * (end - start) + start); target.textContent = value.toLocaleString() + '+'; if (progress < 1) { window.requestAnimationFrame(step); } }; window.requestAnimationFrame(step); } // Intersection Observer to trigger animations when hero section is in view const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { // Animate counter animateCounter(document.getElementById('members-count'), 0, 8500, 2000); // GSAP animations gsap.from(".hero h1", { duration: 1.5, y: 50, opacity: 0, ease: "power3.out" }); gsap.from(".hero p", { duration: 1.5, y: 50, opacity: 0, delay: 0.3, ease: "power3.out" }); gsap.from(".cta-button", { duration: 1, y: 50, opacity: 0, delay: 0.6, ease: "back.out(1.7)" }); gsap.from(".stat-item", { duration: 1, y: 50, opacity: 0, delay: 0.9, stagger: 0.2, ease: "power3.out" }); observer.unobserve(entry.target); } }); }, { threshold: 0.5 }); observer.observe(document.querySelector('.hero'));
Output Preview
Desktop
Mobile
Fullscreen