Toggle navigation
☰
Home
HTML
CSS
Scripting
Database
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Animated On-Scroll List</title> <style> /* ========================================================================== Styles for Demo Preview Only ========================================================================== */ body { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background-color: #f1f5f9; color: #334155; margin: 0; padding: 2rem; display: flex; justify-content: center; } /* ========================================================================== Animated On-Scroll List Component Styles - Copy from here ========================================================================== */ .animated-list-template { --anim-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; --anim-primary-text-color: #1e293b; --anim-secondary-text-color: #64748b; --anim-bg-color: #ffffff; --anim-border-color: #e2e8f0; --anim-duration: 0.5s; font-family: var(--anim-font-family); color: var(--anim-primary-text-color); width: 100%; max-width: 700px; } .animated-list-template *, .animated-list-template *::before, .animated-list-template *::after { box-sizing: border-box; } .animated-list-template .list-header { text-align: center; margin-bottom: 2.5rem; } .animated-list-template .list-header h2 { font-size: 2rem; margin: 0; } .animated-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.5rem; } .animated-item { background-color: var(--anim-bg-color); border: 1px solid var(--anim-border-color); border-radius: .5rem; padding: 1.5rem 2rem; /* Initial state for the animation */ opacity: 0; transform: translateY(20px); transition: opacity var(--anim-duration) ease-out, transform var(--anim-duration) ease-out; } /* The visible state triggered by JavaScript */ .animated-item.is-visible { opacity: 1; transform: translateY(0); } /* Stagger the animation delay for a cascading effect */ .animated-item:nth-child(1) { transition-delay: 0.1s; } .animated-item:nth-child(2) { transition-delay: 0.2s; } .animated-item:nth-child(3) { transition-delay: 0.3s; } .animated-item:nth-child(4) { transition-delay: 0.4s; } .animated-item:nth-child(5) { transition-delay: 0.5s; } .animated-item:nth-child(6) { transition-delay: 0.6s; } .animated-item:nth-child(7) { transition-delay: 0.7s; } </style> </head> <body> <div class="animated-list-template"> <header class="list-header"> <h2>Notable & Unusual Accomplishments</h2> </header> <ul class="animated-list"> <li class="animated-item">Correctly guessed the WiFi password on the first try.</li> <li class="animated-item">Assembled IKEA furniture using only the provided instructions.</li> <li class="animated-item">Explained a movie plot to a friend without getting confused.</li> <li class="animated-item">Kept a houseplant alive for more than a month.</li> <li class="animated-item">Finished a tube of chapstick without losing it.</li> <li class="animated-item">Actually read the entire "Terms and Conditions" document.</li> <li class="animated-item">Muted a conference call before anyone heard the dog barking.</li> </ul> </div> <script> document.addEventListener('DOMContentLoaded', () => { const listContainer = document.querySelector('.animated-list-template'); if (!listContainer) return; const animatedItems = listContainer.querySelectorAll('.animated-item'); const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('is-visible'); // Stop observing the element once it's visible observer.unobserve(entry.target); } }); }, { threshold: 0.1 // Trigger when at least 10% of the item is visible }); animatedItems.forEach(item => { observer.observe(item); }); }); </script> </body> </html>