Elegant 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>Elegant Collapse</title> <style> body { font-family: 'Georgia', serif; background-color: #f0f0f0; margin: 0; padding: 20px; display: flex; justify-content: center; align-items: center; height: 100vh; } .elegant-collapse-container { width: 100%; max-width: 600px; margin: 0 auto; } .elegant-collapse-header { background-color: #2c3e50; color: #ecf0f1; padding: 15px 20px; cursor: pointer; border-top-left-radius: 10px; border-top-right-radius: 10px; transition: background-color 0.3s ease; } .elegant-collapse-header:hover { background-color: #34495e; } .elegant-collapse-content { max-height: 0; overflow: hidden; transition: max-height 0.5s ease; background-color: #ecf0f1; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; padding: 0 20px; } .elegant-collapse-content p { padding: 20px 0; margin: 0; color: #2c3e50; } .elegant-collapse-content.show { max-height: 500px; } </style> </head> <body> <div class="elegant-collapse-container"> <div class="elegant-collapse-header" onclick="toggleElegantCollapse(this)"> Click to Expand </div> <div class="elegant-collapse-content"> <p>This is an elegantly designed collapse component. It is perfect for a more refined and classic look.</p> </div> </div> <script> function toggleElegantCollapse(element) { const header = element; const content = header.nextElementSibling; content.classList.toggle('show'); } </script> </body> </html>