Vibrant Toast Notifications - 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>Vibrant Toast Notifications</title> <style> body { font-family: 'Comic Sans MS', cursive, sans-serif; background-color: #fff; margin: 0; display: flex; justify-content: center; align-items: center; height: 100vh; } .toast-container { position: fixed; bottom: 20px; left: 20px; z-index: 1000; } .toast { display: flex; align-items: center; background-color: #FF5722; color: #fff; padding: 10px 15px; margin-bottom: 10px; border-radius: 20px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); animation: bounceIn 0.5s, fadeOut 0.5s 3.5s forwards; opacity: 0; } .toast-icon { margin-right: 10px; font-size: 24px; } .toast-message { flex-grow: 1; } .toast-close { background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; } @keyframes bounceIn { from { opacity: 0; transform: scale(0.3); } 50% { opacity: 1; transform: scale(1.1); } 70% { transform: scale(0.9); } to { transform: scale(1); } } @keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } } </style> </head> <body> <div class="toast-container" id="toastContainer"></div> <script> function showToast(type, message) { const icons = { success: '✅', error: '❌', info: 'ℹ️', warning: '⚠️' }; const toastContainer = document.getElementById('toastContainer'); const toast = document.createElement('div'); toast.className = 'toast'; const icon = document.createElement('div'); icon.className = 'toast-icon'; icon.innerHTML = icons[type] || 'ℹ️'; const msg = document.createElement('div'); msg.className = 'toast-message'; msg.innerText = message; const closeBtn = document.createElement('button'); closeBtn.className = 'toast-close'; closeBtn.innerHTML = '×'; closeBtn.onclick = () => toast.remove(); toast.appendChild(icon); toast.appendChild(msg); toast.appendChild(closeBtn); toastContainer.appendChild(toast); setTimeout(() => { toast.style.opacity = '1'; }, 100); setTimeout(() => { toast.remove(); }, 4000); } // Example usage: showToast('success', 'Vibrant success message!'); showToast('error', 'Vibrant error message!'); showToast('info', 'Vibrant info message!'); showToast('warning', 'Vibrant warning message!'); </script> </body> </html>