Enchanted Forest 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>Enchanted Forest Popover</title> <style> body { font-family: 'Arial', sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #2e8540; margin: 0; } .popover-container { position: relative; display: inline-block; } .popover-trigger { padding: 10px 20px; background-color: #ffc107; color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; transition: background-color 0.3s ease; } .popover-trigger:hover { background-color: #ffa000; } .popover-content { display: none; position: absolute; top: 150%; left: 50%; transform: translateX(-50%); width: 300px; background-color: #ffffff; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5); 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: #ffc107; 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; color: #333; } .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: #ffc107; color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 14px; transition: background-color 0.3s ease; } .popover-footer button:hover { background-color: #ffa000; } </style> </head> <body> <div class="popover-container"> <button class="popover-trigger">Click me! π³</button> <div class="popover-content"> <div class="popover-header"> <span>Enchanted Forest π²</span> <button class="close-btn">×</button> </div> <div class="popover-body"> <p>Welcome to the enchanted forest popover! π¦</p> <p class="emojis">π²π³πΏπ</p> <p>Step into a magical world with this nature-inspired design.</p> </div> <div class="popover-footer"> <button>Explore the magic! π§ββοΈ</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>