Gallery✨ Premium

Zoom with Overlay

A square follows the mouse, a finger or the arrow keys over your image, and the panel next to it shows exactly that area enlarged twice.

JSOverlay

Updated

This effect is part of Effect.Labs — 840 vanilla effects, some free, some premium. Gallery has 44 effects, including 6 free. Explore the category →

3 usage examples

Dive watch product page — the dial up close — Zoom with Overlay example 1

① Dive watch product page — the dial up close

WhenIn the Abyssaure shop, the Profonde 42 mm photo sits on the left; the detail panel next to it, then the price and “Add to bag”. Hovering the dial, the buyer sees the graduated bezel, the date and the print in large.
WhyA watch buyer wants to judge the finish without losing the overall view: the photo stays whole and the detail appears in a panel that covers nothing.
Settingsdata-zoom="2.4", --zov-width: 240px, --zov-ratio: 9/7, --zov-panel: 170px, orange square matching the hands.
Deep-sky frame in an astronomy club's observing log — Zoom with Overlay example 2

② Deep-sky frame in an astronomy club's observing log

WhenIn the Oudrelle Astronomy Club's observing log, the frame from the night of 14 October fills most of the width; the panel on the right shows the area at four times the size, and the “Found it” and “Nothing seen” buttons wait at the bottom. The member moves the square to find the small spiral galaxy, then the nebula.
WhyOn a sky frame, the target is only a few pixels wide: the square places it on the whole field, the panel shows the object. A strong enlargement gives a small, precise square.
Settingsdata-zoom="4", --zov-width: 340px, --zov-ratio: 540/300, --zov-panel: 152px, square and panel edged in green.
Checking a signature in a back office, on the keyboard — Zoom with Overlay example 3

③ Checking a signature in a back office, on the keyboard

WhenIn Signavelle, the scanned signature of contract SG-48213 fits in a small thumbnail; the elongated panel beside it shows the stroke enlarged. The agent follows the stroke with the arrow keys, then picks “Accept” or “Reject”.
WhyComparing a signature with the specimen means following the stroke closely; a panel shaped like the signature shows a useful stretch of the line, and keyboard navigation keeps the back office's shortcuts at hand.
Settingsdata-zoom="2.5", --zov-width: 170px, --zov-ratio: 9/5, --zov-panel: 155px, --zov-panel-ratio: 9/5. In the capture, the scene focuses the image and sends it the arrow keys the code listens for.

How it works

On the left, the .zov-frame holds your <img class="zov-image"> and the marker square .zov-indicator; on the right, the .zov-result panel is empty in the HTML. The script gives it the image itself as a background, or the data-zoom-src file: there is no longer any image to copy into the panel by hand.

The square's size comes from the panel: panel width divided by data-zoom (2), so 68 px for the default panel (140 px wide, 136 px inside its border). On every move, the square stays inside the image and the panel shows, enlarged, exactly what the square covers, object-fit: cover crop included. At rest, the panel shows the middle of the image.

The script wires each .fx-0184-root separately and follows size changes (ResizeObserver). Image and panel sit side by side and stack when space runs out.

Accessibility

  • Keyboard: the image takes Tab focus, the square appears, arrow keys move it by 10 px (40 px with Shift) and Escape hides it; the panel follows.
  • Touch: putting down and dragging a finger moves the square; page scrolling is held back on the image only (touch-action: none).
  • Screen readers: the image and its alt text are read inside a named group; the square and the panel, purely visual, are hidden (aria-hidden).
  • Reduced motion: under prefers-reduced-motion: reduce, the square appears without a fade; there is no other animation.

Browser compatibility

Pointer Events, object-fit, aspect-ratio, ResizeObserver and close to 4 KB of JavaScript, no dependency. Measured in Chromium 151, Firefox 153 and WebKit 26.5: the buyer's red image correctly shown in the panel, two independent copies, script pasted twice without error, arrow keys, a real finger at 390 px (Chromium), panel moved under the image with no overflow.

Chrome 88+✓ Full (measured)
Firefox 89+✓ Full (measured)
Safari 15+✓ Full (WebKit engine measured)
Edge 88+✓ Full (Chromium engine)
Mobile iOS 15+✓ Full (WebKit engine measured)
Android Chrome 88+✓ Full (Chromium engine)

Without JavaScript, the image shows and the panel stays empty. Without ResizeObserver, the panel is recomputed on the next move after a size change.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0184-root">
  <div class="zov-wrap">
    <div class="zov-frame" tabindex="0" role="group" aria-label="Zoom: hover the image, drag a finger or use the arrow keys; the chosen area appears enlarged next to it" data-zoom="2">
      <img class="zov-image" src="your-photo.jpg" data-zoom-src="your-photo-large.jpg" alt="Photo description">
      <span class="zov-label" aria-hidden="true">Hover</span>
      <div class="zov-indicator" aria-hidden="true"></div>
    </div>
    <div class="zov-result" 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 / propertyDefaultEffect
Image (HTML — src of .zov-image) violet grid pattern (inline SVG) Your photo and its alt. data-zoom-src on the same tag gives the panel a larger, sharper file.
data-zoom (on .zov-frame) 2 Enlargement in the panel; it also sets the square's size (panel ÷ zoom).
--zov-width · --zov-ratio 180px · 9 / 7 Image width and proportions.
--zov-panel · --zov-panel-ratio 140px · 1 Panel width and proportions; an elongated panel gives an elongated marker.
--zov-gap · --zov-radius 1rem · 0.75rem Space between image and panel, rounding of both.
Square colours (.zov-indicator rule) white border, indigo fill at 20% Change border and background to match your brand.

FAQ

No. The panel is a plain empty <div>: the script reuses the frame's image (or data-zoom-src) and keeps it up to date if you change the photo.
It stands for what the panel shows: its size is the panel's divided by data-zoom. Raise the zoom for a smaller square and a stronger detail.
The panel moves under the image when width runs short. A finger moves the square; the page scrolls from the rest of the screen.