Smooth Zoom - 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>Smooth Zoom</title> <style> body { font-family: Arial, sans-serif; background-color: #eaeaea; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .smooth-zoom-container { position: relative; display: inline-block; cursor: pointer; } .smooth-zoom-container img { width: 100%; height: auto; transition: transform 0.5s ease, box-shadow 0.5s ease; border-radius: 12px; box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15); } .smooth-zoom-container:hover img { transform: scale(1.1); box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3); } .smooth-zoom-icon { position: absolute; top: 10px; right: 10px; background-color: rgba(255, 255, 255, 0.9); border-radius: 50%; padding: 5px; font-size: 26px; transition: transform 0.5s ease; } .smooth-zoom-container:hover .smooth-zoom-icon { transform: rotate(360deg); } .smooth-zoom-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.85); display: none; justify-content: center; align-items: center; z-index: 1000; animation: fadeIn 0.5s ease; } .smooth-zoom-overlay img { max-width: 90%; max-height: 90%; border-radius: 12px; box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5); transform: scale(0.8); animation: zoomIn 0.5s ease forwards; } .smooth-zoom-overlay .close-icon { position: absolute; top: 20px; right: 20px; background-color: rgba(255, 255, 255, 0.9); border-radius: 50%; padding: 10px; font-size: 34px; cursor: pointer; transition: transform 0.5s ease; } .smooth-zoom-overlay .close-icon:hover { transform: scale(1.2); } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } @keyframes zoomIn { from { transform: scale(0.8); } to { transform: scale(1); } } </style> </head> <body> <div class="smooth-zoom-container"> <img src="https://via.placeholder.com/600x400" alt="Zoom Image"> <div class="smooth-zoom-icon">🔍</div> </div> <div class="smooth-zoom-overlay" id="smooth-zoom-overlay"> <img src="https://via.placeholder.com/600x400" alt="Zoom Image"> <div class="close-icon" id="smooth-close-icon">❌</div> </div> <script> const smoothZoomContainer = document.querySelector('.smooth-zoom-container'); const smoothZoomOverlay = document.getElementById('smooth-zoom-overlay'); const smoothCloseIcon = document.getElementById('smooth-close-icon'); const smoothZoomImage = smoothZoomContainer.querySelector('img'); const smoothOverlayImage = smoothZoomOverlay.querySelector('img'); smoothZoomContainer.addEventListener('click', () => { smoothOverlayImage.src = smoothZoomImage.src; smoothZoomOverlay.style.display = 'flex'; }); smoothCloseIcon.addEventListener('click', () => { smoothZoomOverlay.style.display = 'none'; }); smoothZoomOverlay.addEventListener('click', (e) => { if (e.target === smoothZoomOverlay) { smoothZoomOverlay.style.display = 'none'; } }); </script> </body> </html>