Zoom In Out Notification Toast - 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>Zoom In/Out Notification Toast</title> <style> body { font-family: 'Arial', sans-serif; background-color: #f7f7f7; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; } .toast { display: flex; align-items: center; background: #777; color: #fff; padding: 20px; margin-bottom: 15px; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); animation: zoomIn 0.5s, fadeOut 0.5s 4.5s; } .toast-icon { font-size: 24px; margin-right: 15px; } .toast-message { flex: 1; font-size: 16px; } .toast-close { background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; } @keyframes zoomIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } } @keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } } .toast-success { background: #388e3c; } .toast-error { background: #d32f2f; } .toast-warning { background: #fbc02d; } .toast-info { background: #1976d2; } </style> </head> <body> <div class="toast-container" id="toast-container"></div> <script> function showToast(type, message) { const toastContainer = document.getElementById('toast-container'); const toast = document.createElement('div'); toast.className = `toast toast-${type}`; const icon = document.createElement('div'); icon.className = 'toast-icon'; switch (type) { case 'success': icon.textContent = '✅'; break; case 'error': icon.textContent = '❌'; break; case 'warning': icon.textContent = '⚠️'; break; case 'info': icon.textContent = 'ℹ️'; break; default: icon.textContent = '🔔'; } const messageDiv = document.createElement('div'); messageDiv.className = 'toast-message'; messageDiv.textContent = message; const closeButton = document.createElement('button'); closeButton.className = 'toast-close'; closeButton.textContent = '×'; closeButton.onclick = () => toastContainer.removeChild(toast); toast.appendChild(icon); toast.appendChild(messageDiv); toast.appendChild(closeButton); toastContainer.appendChild(toast); setTimeout(() => { if (toast.parentNode) { toastContainer.removeChild(toast); } }, 5000); } // Example usage showToast('success', 'Your action was successful!'); showToast('error', 'Something went wrong!'); showToast('warning', 'Please be careful!'); showToast('info', 'Here is some information.'); </script> </body> </html>