Une landing page animée responsive🔗 Ressources : FreeCodeCamp JavaScript.info
- User
Une landing page animée responsive🔗 Ressources : FreeCodeCamp
JavaScript.info
Assistant
Je peux vous aider à créer une landing page animée et responsive ! Voici une approche structurée pour ce projet :
Structure HTML de base
<!DOCTYPE html> <html lang="fr"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Landing Page Animée</title> <link rel="stylesheet" href="styles.css"> </head> <body> <nav class="navbar"> <div class="nav-container"> <a href="#" class="logo">Logo</a> <ul class="nav-menu"> <li><a href="#home">Accueil</a></li> <li><a href="#about">À propos</a></li> <li><a href="#services">Services</a></li> <li><a href="#contact">Contact</a></li> </ul> <div class="hamburger"> <span></span> <span></span> <span></span> </div> </div> </nav> <section id="home" class="hero"> <div class="hero-content"> <h1 class="hero-title">Bienvenue sur notre site</h1> <p class="hero-subtitle">Créons quelque chose d'extraordinaire ensemble</p> <button class="cta-button">Commencer</button> </div> </section> <section id="about" class="section"> <div class="container"> <h2 class="section-title">À propos de nous</h2> <div class="cards"> <div class="card"> <h3>Innovation</h3> <p>Nous repoussons les limites du possible</p> </div> <div class="card"> <h3>Qualité</h3> <p>Excellence dans chaque détail</p> </div> <div class="card"> <h3>Support</h3> <p>Toujours là pour vous accompagner</p> </div> </div> </div> </section> <script src="script.js"></script> </body> </html>CSS avec animations
* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Arial', sans-serif; line-height: 1.6; color: #333; } /* Navigation */ .navbar { position: fixed; top: 0; width: 100%; background: rgba(255, 255, 255, 0.95); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); z-index: 1000; transition: all 0.3s ease; } .nav-container { max-width: 1200px; margin: 0 auto; padding: 1rem 2rem; display: flex; justify-content: space-between; align-items: center; } .logo { font-size: 1.5rem; font-weight: bold; color: #333; text-decoration: none; } .nav-menu { display: flex; list-style: none; gap: 2rem; } .nav-menu a { color: #333; text-decoration: none; transition: color 0.3s ease; } .nav-menu a:hover { color: #007bff; } /* Hamburger menu */ .hamburger { display: none; flex-direction: column; cursor: pointer; } .hamburger span { width: 25px; height: 3px; background: #333; margin: 3px 0; transition: 0.3s; } /* Hero Section */ .hero { height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; text-align: center; } .hero-content { animation: fadeInUp 1s ease; } .hero-title { font-size: 3rem; margin-bottom: 1rem; animation: slideInLeft 1s ease; } .hero-subtitle { font-size: 1.2rem; margin-bottom: 2rem; animation: slideInRight 1s ease 0.3s both; } .cta-button { padding: 12px 30px; font-size: 1.1rem; background: white; color: #667eea; border: none; border-radius: 50px; cursor: pointer; transition: transform 0.3s ease, box-shadow 0.3s ease; animation: fadeIn 1s ease 0.6s both; } .cta-button:hover { transform: translateY(-3px); box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2); } /* Sections */ .section { padding: 80px 0; } .container { max-width: 1200px; margin: 0 auto; padding: 0 2rem; } .section-title { text-align: center; font-size: 2.5rem; margin-bottom: 3rem; } /* Cards */ .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 2rem; } .card { background: white; padding: 2rem; border-radius: 10px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); transition: transform 0.3s ease, box-shadow 0.3s ease; } .card:hover { transform: translateY(-10px); box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15); } /* Animations */ @keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } } @keyframes slideInLeft { from { opacity: 0; transform: translateX(-50px); } to { opacity: 1; transform: translateX(0); } } @keyframes slideInRight { from { opacity: 0; transform: translateX(50px); } to { opacity: 1; transform: translateX(0); } } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } /* Responsive */ @media (max-width: 768px) { .nav-menu { position: fixed; left: -100%; top: 70px; flex-direction: column; background-color: white; width: 100%; text-align: center; transition: 0.3s; box-shadow: 0 10px 27px rgba(0, 0, 0, 0.05); padding: 2rem 0; } .nav-menu.active { left: 0; } .hamburger { display: flex; } .hamburger.active span:nth-child(2) { opacity: 0; } .hamburger.active span:nth-child(1) { transform: translateY(8px) rotate(45deg); } .hamburger.active span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); } .hero-title { font-size: 2rem; } .hero-subtitle { font-size: 1rem; } }JavaScript pour les interactions
// Menu hamburger const hamburger = document.querySelector('.hamburger'); const navMenu = document.querySelector('.nav-menu'); hamburger.addEventListener('click', () => { hamburger.classList.toggle('active'); navMenu.classList.toggle('active'); }); // Fermer le menu quand on clique sur un lien document.querySelectorAll('.nav-menu a').forEach(link => { link.addEventListener('click', () => { hamburger.classList.remove('active'); navMenu.classList.remove('active'); }); }); // Animation au scroll const observerOptions = { threshold: 0.1, rootMargin: '0px 0px -100px 0px' }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.style.animation = 'fadeInUp 1s ease forwards'; } }); }, observerOptions); // Observer les cartes document.querySelectorAll('.card').forEach(card => { observer.observe(card); }); // Smooth scroll document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); const target = document.querySelector(this.getAttribute('href')); if (target) { target.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }); }); // Navbar qui change au scroll let lastScroll = 0; const navbar = document.querySelector('.navbar'); window.addEventListener('scroll', () => { const currentScroll = window.pageYOffset; if (currentScroll > 100) { navbar.style.background = 'rgba(255, 255, 255, 0.98)'; navbar.style.boxShadow = '0 2px 20px rgba(0, 0, 0, 0.1)'; } else { navbar.style.background = 'rgba(255, 255, 255, 0.95)'; navbar.style.boxShadow = '0 2px 10px rgba(0, 0, 0, 0.1)'; } lastScroll = currentScroll; });Cette landing page inclut :
- Design responsive : S'adapte aux différentes tailles d'écran
- Menu hamburger : Pour mobile avec animation
- Animations CSS : Fade in, slide in, et hover effects
- Scroll smooth : Navigation fluide entre sections
- Intersection Observer : Animations au scroll
- Navbar dynamique : Change d'apparence au scroll
Pour aller plus loin, vous pouvez ajouter :
- Plus de sections (témoignages, portfolio, etc.)
- Un formulaire de contact animé
- Des animations de particules ou parallax
- Un loader de page
- Des graphiques animés avec Chart.js
Les ressources que vous avez mentionnées (FreeCodeCamp et JavaScript.info) sont excellentes pour approfondir ces concepts et apprendre de nouvelles techniques d'animation !
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.