Highly Styled 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>Highly Styled Popover</title> <style> body { font-family: 'Arial', sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #f0f0f0; margin: 0; } .popover-container { position: relative; display: inline-block; } .popover-trigger { padding: 10px 20px; background-color: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; transition: background-color 0.3s ease; } .popover-trigger:hover { background-color: #0056b3; } .popover-content { display: none; position: absolute; top: 150%; left: 50%; transform: translateX(-50%); width: 300px; background-color: white; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); z-index: 1000; animation: fadeIn 0.5s ease forwards, slideIn 0.5s ease forwards; } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } @keyframes slideIn { from { transform: translateX(-50%) translateY(20px); } to { transform: translateX(-50%) translateY(0); } } .popover-header { padding: 10px; background-color: #007bff; color: white; border-top-left-radius: 10px; border-top-right-radius: 10px; display: flex; justify-content: space-between; align-items: center; font-size: 18px; } .popover-header .close-btn { background: none; border: none; color: white; font-size: 20px; cursor: pointer; } .popover-body { padding: 20px; font-size: 16px; } .popover-body p { margin: 0 0 10px; } .popover-body .emojis { font-size: 24px; } .popover-footer { padding: 10px; background-color: #f8f9fa; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; display: flex; justify-content: flex-end; } .popover-footer button { padding: 5px 10px; background-color: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 14px; transition: background-color 0.3s ease; } .popover-footer button:hover { background-color: #218838; } </style> </head> <body> <div class="popover-container"> <button class="popover-trigger">Click me! ✨</button> <div class="popover-content"> <div class="popover-header"> <span>Popover Title 🚀</span> <button class="close-btn">×</button> </div> <div class="popover-body"> <p>Welcome to the amazing popover! 🌟</p> <p class="emojis">🎉✨💥💫</p> <p>Use this popover to display important information in a beautiful way.</p> </div> <div class="popover-footer"> <button>Got it! 👍</button> </div> </div> </div> <script> document.addEventListener('DOMContentLoaded', () => { const trigger = document.querySelector('.popover-trigger'); const popover = document.querySelector('.popover-content'); const closeBtn = document.querySelector('.close-btn'); const footerBtn = document.querySelector('.popover-footer button'); trigger.addEventListener('click', () => { popover.style.display = 'block'; }); closeBtn.addEventListener('click', () => { popover.style.display = 'none'; }); footerBtn.addEventListener('click', () => { popover.style.display = 'none'; }); window.addEventListener('click', (event) => { if (event.target !== trigger && !popover.contains(event.target)) { popover.style.display = 'none'; } }); }); </script> </body> </html>