Welcome Here And Thanks For Visiting. Like Us On Facebook...

EXEIdeas – Let's Your Mind Rock » HTML-CSS-PHP-JavaScript / JavaScript Codes » Zoom Image In Circle On Mouseover Using Pure JavaScript

Zoom Image In Circle On Mouseover Using Pure JavaScript

Yet another lightweight image magnifier plugin that helps you to create zoom images on mouseover using JavaScript. It follows the cursor position and dynamically updates the zoomed area of the image.

This simple image zoom plugin is purely built with CSS and JavaScript without any dependency. You can use this to allow users to zoom product images on hover or use it for general-purpose image zoom functionality.

There are many code snippets available online or on many other blogs and websites, but everyone cannot optimize your blog or website, so you need some optimized code snippets. So now checkout out the code snippet for your blog and website that will give you all features for your desired code. Now grab the ready-to-use code and paste it where you want.


  1. Light Weight.
  2. Pure HTML-CSS-JSCode.
  3. Cross Browser.
  4. No JQuery Files.
  5. Fully Customizable.
  6. Responsive.

How To Create Zoom Image In Circle On Mouseover Using Pure JavaScript?

There are a few easy and understandable steps to achieve your desired functionality that we are gonna share below. Follow each step perfectly.

Recommended For You:
How To Show Different Image On Hover Using HTML Code?


<style type="text/css">
#img-zoomer-box {
max-width: 500px;
height: auto;
position: relative;
margin: 10px auto;

#img-1 {
width: 100%;
height: auto;

#img-zoomer-box:hover, #img-zoomer-box:active {
cursor: zoom-in;
display: block;

#img-zoomer-box:hover #img-2, #img-zoomer-box:active #img-2 {
opacity: 1;
#img-2 {
width: 340px;
height: 340px;
background: url('') no-repeat #FFF;
box-shadow: 0 5px 10px -2px rgba(0,0,0,0.3);
pointer-events: none;
position: absolute;
opacity: 0;
border: 4px solid whitesmoke;
z-index: 99;
border-radius: 100%;
display: block;
transition: opacity .2s;


<div id="img-zoomer-box">
<img src="" id="img-1" alt="Zoom Image on Mouseover"/>
<div id="img-2"></div>


<script type="text/javascript">
let zoomer = function (){
.addEventListener('mousemove', function(e) {

let original = document.querySelector('#img-1'),
magnified = document.querySelector('#img-2'),
style =,
x = e.pageX - this.offsetLeft,
y = e.pageY - this.offsetTop,
imgWidth = original.offsetWidth,
imgHeight = original.offsetHeight,
xperc = ((x/imgWidth) * 100),
yperc = ((y/imgHeight) * 100);

//lets user scroll past right edge of image
if(x > (.01 * imgWidth)) {
xperc += (.15 * xperc);

//lets user scroll past bottom edge of image
if(y >= (.01 * imgHeight)) {
yperc += (.15 * yperc);

style.backgroundPositionX = (xperc - 9) + '%';
style.backgroundPositionY = (yperc - 9) + '%';

style.left = (x - 180) + 'px'; = (y - 180) + 'px';

}, false);


No need to customize it. Just copy-paste. Rest edit the code as per comments and need.

Troubleshooting the Errors:

Do it with concentration and patience. Check your all steps again and all codes or scripts. If you find any error you can contact us anytime via comment or better via email, We are always here to help you.

Final Words:

That’s all we have. We hope that you liked this article. If you have any problem with this code in your template then feel free to contact us with a full explanation of your problem. We will reply to you as time allows us If you have any doubts or problems please comment below. We are happy to help you! If you liked this article, Don’t forget to share this with your friends so they can also take benefit from it and leave.

Recommended For You:
Simple Customizable Toast Notification In Vanilla JavaScript

You Like It, Please Share This Recipe With Your Friends Using...

Be the first to write a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *