Gradient 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>Gradient Accordion</title> <style> body { font-family: 'Montserrat', Arial, sans-serif; background-color: #f8f8f8; margin: 0; display: flex; justify-content: center; align-items: center; height: 100vh; } .accordion { width: 400px; background: linear-gradient(120deg, #00c6ff, #0072ff); border-radius: 10px; box-shadow: 0 4px 10px rgba(0,0,0,0.2); overflow: hidden; color: #fff; } .accordion-item { border-bottom: 1px solid rgba(255,255,255,0.2); } .accordion-title { padding: 15px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-size: 18px; font-weight: bold; color: #fff; } .accordion-content { padding: 15px; display: none; font-size: 16px; color: #fff; } .accordion-title.active { background-color: rgba(255,255,255,0.1); } .accordion-title.active .accordion-icon { transform: rotate(90deg); } .accordion-icon { transition: transform 0.3s ease; } .accordion-title:hover { background-color: rgba(255,255,255,0.2); } </style> </head> <body> <div class="accordion"> <div class="accordion-item"> <div class="accordion-title"> Section 1 <span class="accordion-icon">▶</span> </div> <div class="accordion-content"> Content of section 1 goes here. </div> </div> <div class="accordion-item"> <div class="accordion-title"> Section 2 <span class="accordion-icon">▶</span> </div> <div class="accordion-content"> Content of section 2 goes here. </div> </div> <div class="accordion-item"> <div class="accordion-title"> Section 3 <span class="accordion-icon">▶</span> </div> <div class="accordion-content"> Content of section 3 goes here. </div> </div> </div> <script> document.addEventListener('DOMContentLoaded', function() { const accordionItems = document.querySelectorAll('.accordion-item'); accordionItems.forEach(item => { const title = item.querySelector('.accordion-title'); const content = item.querySelector('.accordion-content'); title.addEventListener('click', () => { title.classList.toggle('active'); if (title.classList.contains('active')) { content.style.display = 'block'; } else { content.style.display = 'none'; } }); }); }); </script> </body> </html>