Professional Image 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>Professional Image Zoom</title> <style> body { font-family: Arial, sans-serif; background-color: #f0f0f0; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .zoom-container { position: relative; display: inline-block; cursor: zoom-in; } .zoom-container img { width: 100%; height: auto; transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); } .zoom-container:hover img { transform: scale(1.05); box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); } .zoom-icon { position: absolute; top: 10px; right: 10px; background-color: rgba(255, 255, 255, 0.8); border-radius: 50%; padding: 5px; font-size: 24px; transition: transform 0.3s ease-in-out; } .zoom-container:hover .zoom-icon { transform: scale(1.2); } .zoom-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.8); display: none; justify-content: center; align-items: center; z-index: 999; animation: fadeIn 0.3s ease-in-out; } .zoom-overlay img { max-width: 90%; max-height: 90%; border-radius: 10px; box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5); transform: scale(0.8); animation: zoomIn 0.3s ease-in-out forwards; } .zoom-overlay .close-icon { position: absolute; top: 20px; right: 20px; background-color: rgba(255, 255, 255, 0.8); border-radius: 50%; padding: 10px; font-size: 32px; cursor: pointer; transition: transform 0.3s ease-in-out; } .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="zoom-container"> <img src="https://via.placeholder.com/600x400" alt="Zoom Image"> <div class="zoom-icon">🔍</div> </div> <div class="zoom-overlay" id="zoom-overlay"> <img src="https://via.placeholder.com/600x400" alt="Zoom Image"> <div class="close-icon" id="close-icon">❌</div> </div> <script> const zoomContainer = document.querySelector('.zoom-container'); const zoomOverlay = document.getElementById('zoom-overlay'); const closeIcon = document.getElementById('close-icon'); const zoomImage = zoomContainer.querySelector('img'); const overlayImage = zoomOverlay.querySelector('img'); zoomContainer.addEventListener('click', () => { overlayImage.src = zoomImage.src; zoomOverlay.style.display = 'flex'; }); closeIcon.addEventListener('click', () => { zoomOverlay.style.display = 'none'; }); zoomOverlay.addEventListener('click', (e) => { if (e.target === zoomOverlay) { zoomOverlay.style.display = 'none'; } }); </script> </body> </html>