Conclusion
I hope after that you will no more struggle to create a zoom effect. You don’t need a lot of funky code or complex libraries to achieve it. Here is again the full code you need to create a cool zoom effect easy to control.
HTML
<img src="" alt="">
CSS
img {
/* the coordinate of the zoom */
--x: 50%;
--y: 50%;
/**/
transform: scale(var(--zoom));
transform-origin: var(--x) var(--y);
clip-path: inset(
calc((1 - 1/var(--zoom)) * (var(--y)))
calc((1 - 1/var(--zoom)) * (100% - var(--x)))
calc((1 - 1/var(--zoom)) * (100% - var(--y)))
calc((1 - 1/var(--zoom)) * (var(--x)))
);
width: 200px;
cursor: crosshair;
}
JavaScript (optional)
let img = document.querySelector("img");
img.onmousemove = function(e) {
e.target.style.setProperty('--x',(100*e.offsetX/e.target.offsetWidth)+'%');
e.target.style.setProperty('--y',(100*e.offsetY/e.target.offsetHeight)+'%');
}
Frequently Asked Questions
How do I get migrated to Verpex?
The migration process is as easy as you can imagine! Regardless of how many websites you’re managing, we’ll bring all of them under the Verpex wing free of charge. Just send us the details of your websites when you’ve signed up to get started.
Are website builders easy to use?
One of the easiest ways to build a website is with a website builder. Using a website builder doesn't require any programming and coding skills.
Can you migrate my existing website over?
Yes, and without issue. Regardless of how many websites you’re managing, we’ll bring all of them under the Verpex wing free of charge. Just send us the details of your websites when you’ve signed up to get started.
What are the customization options with a website builder?
Although website builders usually have some customization settings, like templates, fonts, margins editing, and so on, when compared to CMSs, it lacks customization options.