<div class="image-zoom-container"> <img src="https://placehold.co/400x300/3498db/ffffff?text=Hover+Me" alt="Zoomable Image"> </div>
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #f0f0f0;
margin: 0;
}
.image-zoom-container {
width: 400px; /* Set container width */
height: 300px; /* Set container height */
overflow: hidden; /* This is crucial to hide the parts of the image that zoom out */
border-radius: 8px;
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}
.image-zoom-container img {
width: 100%;
height: 100%;
object-fit: cover; /* Ensures the image covers the container, might crop */
transition: transform 0.5s ease; /* Smooth transition for the zoom effect */
display: block; /* Remove extra space below image */
}
.image-zoom-container:hover img {
transform: scale(1.2); /* Zoom factor - adjust as needed */
}Nothing to show yetType HTML, CSS or JavaScript and your page appears here.
Click any element to find its code Esc
Check this code before you run it
It came from a shared link. It runs with fewer permissions, so it cannot open pop-ups, submit forms or start downloads.
0.00s / 0.00s
Nothing has animated yet. Hover, click or type in the preview and each CSS animation, transition or
element.animate() call shows up here as it plays.