<h1>CSS only Image Zoom</h1>
<p class="zoom-area">This is a solution to make a simple image zoom on mouse hover with <b>CSS</b>. Two versions of the same image are needed, one for the thumnail and other for the full-size or they could be the same image. Try me hovering any of the following images:</p>
<div class="images-container">
<div class="container-enlarge">
<img src="https://i.pinimg.com/564x/44/94/61/44946165fd493cd18e3622907db03174.jpg">
<span><img src="https://i.pinimg.com/564x/44/94/61/44946165fd493cd18e3622907db03174.jpg"></span>
</div>
<div class="container-enlarge">
<img src="https://i.pinimg.com/564x/25/fc/0b/25fc0ba3b86b242fb694b5fe2ae81a97.jpg">
<span><img src="https://i.pinimg.com/564x/25/fc/0b/25fc0ba3b86b242fb694b5fe2ae81a97.jpg"></span>
</div>
<div class="container-enlarge">
<img src="https://i.pinimg.com/564x/99/eb/ad/99ebad60a0173fcecdc71f84def1024d.jpg">
<span><img src="https://i.pinimg.com/564x/99/eb/ad/99ebad60a0173fcecdc71f84def1024d.jpg"></span>
</div>
</div>
<div class="link-container">
<a target="_blank" href="https://www.silocreativo.com/zoom-imagenes-css-hover/" class="more-link">Visit the original article</a>
</div>
.images-container {
width: 90%;
text-align: center;
margin: 60px auto 60px;
}
.container-enlarge {
display: inline-block;
position: relative;
z-index: 0;
margin: 15px;
}
.container-enlarge > img {
height: auto;
max-width: 100%;
width: 150px;
border-radius: 5px;
}
.container-enlarge span {
position: absolute;
top: -9999em;
left: -9999em;
}
.container-enlarge:hover span {
top: -320px;
left: -75px;
width: 300px;
}
/* demo stuff */
body {
background-color: #eff7f2;
margin-bottom: 50px;
}
html, button, input, select, textarea {
font-family: 'Source Sans Pro', Helvetica, sans-serif;
color: #4CAF50;
}
h1 {
text-align: center;
margin: 30px 15px;
}
.zoom-area {
max-width: 390px;
margin: 50px auto 80px;
font-size: 19px;
color: #999;
}
.link-container {
text-align: center;
}
a.more-link {
font-family: 'Source Sans Pro', Helvetica, sans-serif;
background-color: #4CAF50;
padding: 8px 10px;
border-radius: 0;
color: #fff;
display: inline-block;
margin-right: 5px;
margin-bottom: 5px;
line-height: 1.5;
text-decoration: none;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.