Futuristic Accordion - VexaX
Run Code
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>Futuristic Accordion</title> <style> body { display: none; font-family: 'Roboto', sans-serif; background: #222; color: #fff; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .accordion { background: #333; border-radius: 10px; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5); overflow: hidden; width: 100%; max-width: 800px; } .accordion-item { border-bottom: 1px solid #444; } .accordion-item:last-child { border-bottom: none; } .accordion-header { background: #444; color: #fff; cursor: pointer; padding: 25px; font-size: 1.5rem; transition: background 0.3s; display: flex; justify-content: space-between; align-items: center; } .accordion-header:hover { background: #555; } .accordion-content { background: #222; color: #fff; display: none; padding: 25px; animation: expand 0.5s 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 expand { from { max-height: 0; opacity: 0; } to { max-height: 300px; opacity: 1; } } </style> </head> <body> <div class="accordion"> <div class="accordion-item"> <div class="accordion-header"> <h3>Segment 1 <span>🔮</span></h3> <span class="icon">▼</span> </div> <div class="accordion-content"> <p>Futuristic content for the first segment goes here.</p> </div> </div> <div class="accordion-item"> <div class="accordion-header"> <h3>Segment 2 <span>🚀</span></h3> <span class="icon">▼</span> </div> <div class="accordion-content"> <p>Futuristic content for the second segment goes here.</p> </div> </div> <div class="accordion-item"> <div class="accordion-header"> <h3>Segment 3 <span>🛸</span></h3> <span class="icon">▼</span> </div> <div class="accordion-content"> <p>Futuristic content for the third segment 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>