Elegant Dark Popover - 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 Dark Popover</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"> <style> body { font-family: Arial, sans-serif; background-color: #f0f2f5; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .popover-container { position: relative; display: inline-block; } .popover-trigger { padding: 10px 20px; font-size: 18px; border: none; background-color: #333; color: white; border-radius: 5px; cursor: pointer; transition: background-color 0.3s ease; } .popover-trigger:hover { background-color: #555; } .popover-content { visibility: hidden; opacity: 0; width: 300px; background-color: #333; color: white; border-radius: 8px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); position: absolute; z-index: 1; top: 120%; left: 50%; transform: translateX(-50%); transition: opacity 0.4s, visibility 0.4s, transform 0.4s; } .popover-container.show .popover-content { visibility: visible; opacity: 1; transform: translateX(-50%) translateY(0); } .popover-header { background-color: #555; color: white; padding: 10px; border-top-left-radius: 8px; border-top-right-radius: 8px; display: flex; justify-content: space-between; align-items: center; } .popover-header h3 { margin: 0; font-size: 18px; } .popover-body { padding: 20px; font-size: 16px; } .popover-body .icon { font-size: 40px; color: #4CAF50; } .popover-footer { padding: 10px; background-color: #444; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; text-align: right; } .popover-footer button { padding: 5px 15px; font-size: 14px; border: none; background-color: #4CAF50; color: white; border-radius: 5px; cursor: pointer; transition: background-color 0.3s ease; } .popover-footer button:hover { background-color: #45a049; } .popover-emoji { font-size: 24px; margin-left: 10px; } @keyframes bounce { 0%, 20%, 50%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-15px); } 60% { transform: translateY(-7px); } } .popover-header .fa-info-circle { animation: bounce 2s infinite; } </style> </head> <body> <div class="popover-container"> <button class="popover-trigger">Click me</button> <div class="popover-content"> <div class="popover-header"> <h3>Elegant Dark Popover <i class="fas fa-info-circle"></i></h3> <span class="popover-emoji">🌙</span> </div> <div class="popover-body"> <div class="icon"> <i class="fas fa-moon"></i> </div> <div> <p>This popover features an elegant dark theme with contrasting colors.</p> </div> </div> <div class="popover-footer"> <button>Close</button> </div> </div> </div> <script> document.querySelector('.popover-trigger').addEventListener('click', function() { const popoverContainer = this.closest('.popover-container'); popoverContainer.classList.toggle('show'); }); document.querySelector('.popover-footer button').addEventListener('click', function() { const popoverContainer = this.closest('.popover-container'); popoverContainer.classList.remove('show'); }); // Close popover when clicking outside window.addEventListener('click', function(event) { const popovers = document.querySelectorAll('.popover-container'); popovers.forEach(function(popover) { if (!popover.contains(event.target)) { popover.classList.remove('show'); } }); }); </script> </body> </html>