Sunset Orange Collapse - 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>Sunset Orange Collapse</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, #ff6f61, #d74277); height: 100vh; display: flex; justify-content: center; align-items: center; } .collapse-container { width: 80%; max-width: 600px; background: rgba(255, 255, 255, 0.5); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); padding: 20px; } .collapse-item { margin: 10px 0; overflow: hidden; } .collapse-header { background: rgba(255, 255, 255, 0.6); border: 1px solid rgba(255, 255, 255, 0.8); padding: 15px; cursor: pointer; transition: background 0.3s, box-shadow 0.3s; display: flex; justify-content: space-between; align-items: center; color: #333; } .collapse-header:hover { background: rgba(255, 255, 255, 0.7); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); } .collapse-content { max-height: 0; overflow: hidden; background: rgba(255, 255, 255, 0.4); border-top: 1px solid rgba(255, 255, 255, 0.6); transition: max-height 0.3s ease-out; } .collapse-content p { padding: 15px; margin: 0; color: #333; } .collapse-item.active .collapse-content { max-height: 300px; /* Adjust based on content height */ } .collapse-item.active .collapse-header { background: rgba(255, 255, 255, 0.7); } .collapse-header i { transition: transform 0.3s; } .collapse-item.active .collapse-header i { transform: rotate(180deg); } </style> </head> <body> <div class="collapse-container"> <div class="collapse-item"> <div class="collapse-header"> <span>Sunset Collapse Item 1</span> <i class="fas fa-chevron-down"></i> </div> <div class="collapse-content"> <p>This is the content for Sunset Collapse Item 1. It is hidden by default and will be revealed when the header is clicked.</p> </div> </div> <div class="collapse-item"> <div class="collapse-header"> <span>Sunset Collapse Item 2</span> <i class="fas fa-chevron-down"></i> </div> <div class="collapse-content"> <p>This is the content for Sunset Collapse Item 2. It is hidden by default and will be revealed when the header is clicked.</p> </div> </div> </div> <script> document.querySelectorAll('.collapse-header').forEach(header => { header.addEventListener('click', function() { const item = this.parentElement; const isActive = item.classList.contains('active'); document.querySelectorAll('.collapse-item').forEach(i => i.classList.remove('active')); if (!isActive) { item.classList.add('active'); } }); }); </script> </body> </html>