Vibrant Accordion - MeggiTools
Run
Toggle Theme
Share Link
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Vibrant Accordion</title> <style> body { font-family: 'Arial', sans-serif; background: linear-gradient(45deg, #ff6b6b, #f5f5f5); display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .accordion { background: #fff; border-radius: 15px; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); overflow: hidden; width: 100%; max-width: 700px; } .accordion-item { border-bottom: 1px solid #ddd; } .accordion-item:last-child { border-bottom: none; } .accordion-header { background: #ff6b6b; color: #fff; cursor: pointer; padding: 20px; font-size: 1.4rem; transition: background 0.3s; display: flex; justify-content: space-between; align-items: center; } .accordion-header:hover { background: #e63946; } .accordion-content { background: #fff; color: #333; display: none; padding: 20px; animation: slideIn 0.4s forwards; } .accordion-content p { margin: 0; } .accordion-item.active .accordion-content { display: block; } .icon { font-size: 1.5rem; transition: transform 0.3s; } .accordion-item.active .icon { transform: rotate(180deg); } @keyframes slideIn { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } } </style> </head> <body> <div class="accordion"> <div class="accordion-item"> <div class="accordion-header"> <h3>Panel 1 <span>🔥</span></h3> <span class="icon">▼</span> </div> <div class="accordion-content"> <p>Vibrant content for the first panel goes here.</p> </div> </div> <div class="accordion-item"> <div class="accordion-header"> <h3>Panel 2 <span>🎨</span></h3> <span class="icon">▼</span> </div> <div class="accordion-content"> <p>Vibrant content for the second panel goes here.</p> </div> </div> <div class="accordion-item"> <div class="accordion-header"> <h3>Panel 3 <span>✨</span></h3> <span class="icon">▼</span> </div> <div class="accordion-content"> <p>Vibrant content for the third panel goes here.</p> </div> </div> </div> <script> document.querySelectorAll('.accordion-header').forEach(header => { header.addEventListener('click', () => { const accordionItem = header.parentElement; const isActive = accordionItem.classList.contains('active'); document.querySelectorAll('.accordion-item').forEach(item => { item.classList.remove('active'); }); if (!isActive) { accordionItem.classList.add('active'); } }); }); </script> </body> </html>