Lens Zoom
An 80 px square viewfinder with a thin edge lands wherever the mouse, a finger or the keyboard points and shows your image enlarged 2.5 times, with no rounding to shave off the corners.
Updated
This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Gallery has 44 effects, including 6 free. Explore the category →
3 usage examples



How it works
The HTML is three parts inside .lnz-frame: your <img class="lnz-image">, an optional caption and an empty square, .lnz-lens. While nobody is aiming, the square is transparent. On the first move, the script gives it the image file as a background (or the one in data-zoom-src) and adds the is-active class to the frame: the viewfinder appears in 0.2 s.
After that it all comes down to two numbers. The viewfinder background is stretched to the size of the displayed image multiplied by data-zoom: for the original frame, 278 px wide inside, that makes 695 px, or 2.5 times. Then it is shifted so the targeted point lands in the middle of the square. Read while aiming at (100, 60) then (200, 150): the centre of the viewfinder sits exactly at those coordinates in Chromium, Firefox and WebKit.
Near an edge the viewfinder sticks out and the frame cuts it (overflow: hidden), so you can aim right up to the last pixel. The script adds no global name and only attaches to the .fx-0181-root blocks it finds; pasted twice in the page, it duplicates nothing.
Accessibility
- With the keyboard: Tab brings focus to the frame, ringed with a white line, and the viewfinder lights up in the centre. Each arrow key pushes it 12 px, 48 px with Shift; Escape turns it off, and so does leaving the frame. Checked on two neighbouring frames: only the focused one reacts.
- With a finger: the viewfinder appears under the finger, follows it while it drags and goes off when it lifts, so a quick tap lights it only for an instant. Two limits to know: the finger hides part of an 80 px viewfinder (raise
--lnz-sizeto 120 px or more on mobile), and the frame holds the gesture (touch-action: none), so the page does not scroll when you start from the image. - Screen readers: the frame is announced as a group with the instruction in its
aria-label(remember to translate it), the image with itsalt. The viewfinder is purely visual and hidden: if the image holds text to be read, provide that text elsewhere on the page. - “Reduce motion” preference: the 0.2 s fade-in is removed and the viewfinder shows at once. Its movement stays, since it only follows the hand.
Browser compatibility
A 4 KB script with no library, built on Pointer Events; on the CSS side, aspect-ratio sets the frame shape and object-fit: cover the crop. Bench-tested on 4 December 2026 on Chromium 149, Firefox 151 and WebKit 26.5: aiming with the mouse, keyboard path and emulated finger tap in all three; finger down then dragged in Chromium only (the page did not scroll).
If the script fails to load, an ordinary image remains in its frame. The versions listed are those of aspect-ratio (MDN data): on anything older, the frame has no imposed proportion and takes the natural height of the image.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="fx-0181-root">
<div class="lnz-frame" tabindex="0" role="group" aria-label="Magnifier: hover the image, drag a finger or use the arrow keys" data-zoom="2.5">
<img class="lnz-image" src="photo.jpg" data-zoom-src="photo-large.jpg" alt="What the photo shows">
<span class="lnz-label" aria-hidden="true">Move Mouse</span>
<div class="lnz-lens" aria-hidden="true"></div>
</div>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
Image (HTML — src, alt and data-zoom-src of .lnz-image) |
violet grid pattern (SVG in the code) | Your photo. data-zoom-src is optional: it names a heavier file, loaded only when the viewfinder lights up. |
data-zoom (on .lnz-frame) |
2.5 | Magnification. The script rereads it on every move, so you can change it on the fly, with a slider for instance. |
--lnz-size |
80px | Side of the viewfinder. The bigger it is, the more context you see; 120 px or more for finger use. |
--lnz-shape |
0 | Corner rounding of the viewfinder. Leave 0 for the crisp square, 6px to soften it. |
--lnz-ring |
2px solid rgba(255, 255, 255, 0.8) | Edge of the viewfinder. A solid white stands out better on a light photo. |
--lnz-width · --lnz-ratio · --lnz-radius |
280px · 7 / 5 · 0.75rem | Maximum width, proportion and corners of the frame. The image is cropped to fill it. |
.lnz-label caption |
“Move Mouse” | Word shown in the middle of the demo pattern. Delete it as soon as you put in a real image. |
FAQ
data-zoom attribute give you almost the other.