Professional 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>Professional Accordion</title> <style> body { font-family: 'Arial', sans-serif; background: #f0f0f0; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .accordion { background: #fff; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); overflow: hidden; width: 100%; max-width: 600px; } .accordion-item { border-bottom: 1px solid #e5e5e5; } .accordion-item:last-child { border-bottom: none; } .accordion-header { background: #007BFF; color: #fff; cursor: pointer; display: flex; justify-content: space-between; align-items: center; padding: 20px; transition: background 0.3s; } .accordion-header:hover { background: #0056b3; } .accordion-header h3 { margin: 0; font-size: 1.25rem; } .accordion-header .icon { font-size: 1.5rem; transition: transform 0.3s; } .accordion-content { background: #f9f9f9; color: #333; display: none; padding: 20px; animation: fadeIn 0.3s forwards; } .accordion-content p { margin: 0; } .accordion-item.active .accordion-content { display: block; } .accordion-item.active .accordion-header .icon { transform: rotate(45deg); } @keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } .emoji { margin-left: 10px; } </style> </head> <body> <div class="accordion"> <div class="accordion-item"> <div class="accordion-header"> <h3>Accordion Item 1 <span class="emoji">😀</span></h3> <span class="icon">➕</span> </div> <div class="accordion-content"> <p>Content for the first accordion item goes here. It can be anything from text, images, or other HTML elements.</p> </div> </div> <div class="accordion-item"> <div class="accordion-header"> <h3>Accordion Item 2 <span class="emoji">🚀</span></h3> <span class="icon">➕</span> </div> <div class="accordion-content"> <p>Content for the second accordion item goes here. It can be anything from text, images, or other HTML elements.</p> </div> </div> <div class="accordion-item"> <div class="accordion-header"> <h3>Accordion Item 3 <span class="emoji">🌟</span></h3> <span class="icon">➕</span> </div> <div class="accordion-content"> <p>Content for the third accordion item goes here. It can be anything from text, images, or other HTML elements.</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>