Skip to content

Product Card with Image Zoom

Pure CSS product card whose photo zooms smoothly on hover or focus, following the pointer, with rating, color swatches and price.

Also known as: product card zoom, image zoom on hover, ecommerce product card, product card with swatches

Product Card with Image Zoom live demo

Open in new tab

Pure CSS code (HTML, CSS, JS)

A pure CSS product card with a large photo that zooms in smoothly when the shopper hovers over the card or tabs into it. It pairs the image with a category line, star rating, short copy, color swatches, a sale price and an add-to-bag link, and suits shop grids, featured product blocks and landing pages.

How it works

The wrapper .pz-stage sets all colors and sizes as custom properties and centers one article.pz-card. The card is a CSS grid: a single column on phones and two equal columns from 640px, with .pz-media on the left and .pz-body on the right. .pz-media has overflow: hidden and holds the .pz-img photo, the .pz-tag label and the .pz-hint pill.

The zoom is a transform: scale() on .pz-img with an eased transition. It is triggered by .pz-card:hover and .pz-card:focus-within, so keyboard users see the same effect when the swatches or the button get focus. At the same moment the hint pill fades and slides away. The image uses transform-origin: var(--pz-x) var(--pz-y).

The small script.js is optional. On devices with a fine pointer it listens for pointermove on .pz-media and writes the cursor position into --pz-x and --pz-y, so the area under the cursor is magnified. On pointerleave the values are removed and the origin returns to the default. Without JavaScript the card still zooms toward the center.

The swatches are real radio buttons inside a fieldset.pz-swatches; :has(input:checked) draws the ring around the selected .pz-swatch.

Customization

  • --pz-zoom on .pz-stage: the scale factor on hover, e.g. 1.15 for a subtle zoom or 1.6 for a close-up.
  • --pz-speed: duration of the zoom transition; raise it for a slower, more cinematic move.
  • --pz-x and --pz-y on .pz-media: the default zoom origin (currently 50% and 55%) used before the pointer moves and without JavaScript.
  • --pz-accent and --pz-accent-dark: the button color, its hover color and the category text.
  • --pz-sale: the color of .pz-price-now; set it to --pz-text for items that are not on sale and remove .pz-price-old.
  • .pz-swatch--teal, .pz-swatch--sand and .pz-swatch--cocoa: each sets --pz-dot; add a modifier for more colors.
  • grid-template-columns in the 640px media query: use 1.2fr 1fr to give the photo more room.

Use cases

  • Shop grids: product photos zoom toward the cursor so shoppers can inspect details
  • Featured product blocks: a two-column card shows rating, copy, color swatches and a sale price
  • Landing pages: a single product card with an add-to-bag link highlights one item
  • Fashion and home stores: radio color swatches let shoppers choose a color before buying

Accessibility

The card is an article labelled by its heading through aria-labelledby. The photo has a descriptive alt, and the decorative hint is aria-hidden. The swatches are a native radio group with a legend, so arrow keys work and screen readers announce each color name from the visually hidden .pz-sr text. The old price is announced as "Was". Swatches and the button show a clear focus outline. With prefers-reduced-motion: reduce the scaling is replaced by a slight brightness change, and on touch screens the hint is hidden.

Usage notes

The photo comes from Unsplash; replace it with your own product image. Use a different name on the radio inputs for every card on the page.

Product Card with Image Zoom at a glance

Framework
Pure CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
None
Layout
Responsive, works on mobile
Category
Product Cards
License
Free for personal and commercial use

Questions about this template

Can I use the Product Card with Image Zoom code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

There is nothing to install. Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

No dependencies. Pure HTML, CSS and JavaScript.

Product Card with Image Zoom – free Pure CSS product card template
Product Card with Image Zoom · free Pure CSS product card template

More Product Cards

Product Card with Quick Actions – free Pure CSS product card template

Product Card with Quick Actions

Responsive product card grid where hover or focus reveals wishlist, quick view and add-to-cart actions, with star ratings and a native quick view dialog.

Product Card with Sale Badge and Photo – free Bootstrap 5 product card template

Product Card with Sale Badge and Photo

Bootstrap 5 horizontal product card with a corner sale ribbon, discount sticker, old and new prices, size options that recalculate savings and stock bar.

Product Card with Color Options – free Tailwind CSS product card template

Product Card with Color Options

Tailwind CSS product card with live-recoloring color swatches, a size selector with sold-out state, wishlist toggle and add to bag button.