Dark Mode 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>Dark Mode Accordion</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"> <style> body { font-family: 'Arial', sans-serif; background-color: #333; margin: 0; padding: 20px; display: flex; justify-content: center; align-items: center; height: 100vh; color: #fff; } .accordion { width: 80%; max-width: 600px; background: #444; border-radius: 5px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5); } .accordion-item { border-bottom: 1px solid #555; } .accordion-item:last-child { border-bottom: none; } .accordion-header { padding: 15px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; background-color: #444; color: #fff; transition: background-color 0.3s ease; } .accordion-header:hover { background-color: #555; } .accordion-header .icon { transition: transform 0.3s ease; } .accordion-header.active .icon { transform: rotate(180deg); } .accordion-content { padding: 15px; display: none; animation: fadeIn 0.3s forwards; background-color: #555; } @keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } .accordion-content p { margin: 0; padding: 0; } .accordion-content ul { list-style: none; padding: 0; } .accordion-content ul li { margin-bottom: 10px; display: flex; align-items: center; } .accordion-content ul li .emoji { margin-right: 10px; font-size: 1.2em; } </style> </head> <body> <div class="accordion"> <div class="accordion-item"> <div class="accordion-header"> <span>Section 1</span> <i class="fas fa-chevron-down icon"></i> </div> <div class="accordion-content"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> <ul> <li><span class="emoji">🔥</span> Feature 1</li> <li><span class="emoji">⭐</span> Feature 2</li> <li><span class="emoji">💡</span> Feature 3</li> </ul> </div> </div> <div class="accordion-item"> <div class="accordion-header"> <span>Section 2</span> <i class="fas fa-chevron-down icon"></i> </div> <div class="accordion-content"> <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p> <ul> <li><span class="emoji">🌟</span> Benefit 1</li> <li><span class="emoji">🚀</span> Benefit 2</li> <li><span class="emoji">🎉</span> Benefit 3</li> </ul> </div> </div> <div class="accordion-item"> <div class="accordion-header"> <span>Section 3</span> <i class="fas fa-chevron-down icon"></i> </div> <div class="accordion-content"> <p>Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</p> <ul> <li><span class="emoji">💪</span> Advantage 1</li> <li><span class="emoji">🏆</span> Advantage 2</li> <li><span class="emoji">📈</span> Advantage 3</li> </ul> </div> </div> </div> <script> document.querySelectorAll('.accordion-header').forEach(header => { header.addEventListener('click', () => { const accordionItem = header.parentElement; const accordionContent = header.nextElementSibling; header.classList.toggle('active'); accordionContent.style.display = accordionContent.style.display === 'block' ? 'none' : 'block'; }); }); </script> </body> </html>