Minty Fresh 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>Minty Fresh Accordion</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"> <style> body { margin: 0; font-family: Arial, sans-serif; background: linear-gradient(to right, #a8ff78, #78ffd6); height: 100vh; display: flex; justify-content: center; align-items: center; } .accordion-container { width: 80%; max-width: 600px; background: rgba(255, 255, 255, 0.3); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); padding: 20px; } .accordion-item { margin: 10px 0; overflow: hidden; } .accordion-header { background: rgba(255, 255, 255, 0.4); border: 1px solid rgba(255, 255, 255, 0.6); padding: 15px; cursor: pointer; transition: background 0.3s, box-shadow 0.3s; display: flex; justify-content: space-between; align-items: center; } .accordion-header:hover { background: rgba(255, 255, 255, 0.5); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); } .accordion-content { max-height: 0; overflow: hidden; background: rgba(255, 255, 255, 0.2); border-top: 1px solid rgba(255, 255, 255, 0.4); transition: max-height 0.3s ease-out; } .accordion-content p { padding: 15px; margin: 0; } .accordion-item.active .accordion-content { max-height: 300px; /* Adjust based on content height */ } .accordion-item.active .accordion-header { background: rgba(255, 255, 255, 0.5); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3); } .accordion-header i { transition: transform 0.3s; } .accordion-item.active .accordion-header i { transform: rotate(180deg); } </style> </head> <body> <div class="accordion-container"> <div class="accordion-item"> <div class="accordion-header"> <span>Item 1</span> <i class="fas fa-chevron-down"></i> </div> <div class="accordion-content"> <p>Content for Item 1.</p> </div> </div> <div class="accordion-item"> <div class="accordion-header"> <span>Item 2</span> <i class="fas fa-chevron-down"></i> </div> <div class="accordion-content"> <p>Content for Item 2.</p> </div> </div> <div class="accordion-item"> <div class="accordion-header"> <span>Item 3</span> <i class="fas fa-chevron-down"></i> </div> <div class="accordion-content"> <p>Content for Item 3.</p> </div> </div> </div> <script> document.querySelectorAll('.accordion-header').forEach(header => { header.addEventListener('click', () => { const item = header.parentElement; const isActive = item.classList.contains('active'); document.querySelectorAll('.accordion-item').forEach(i => i.classList.remove('active')); if (!isActive) { item.classList.add('active'); } }); }); </script> </body> </html>