UtilitiesPremium

Breakpoint Morphing Cards

A product card in three zones — visual, text, buttons — that rearranges at 280 then 420 px, while its visual and pictogram grow in 0.4 s.

CSS@containerMorph

Updated

This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Utilities has 43 effects, including 3 free. Explore the category →

3 usage examples

Product sheet for a pair of shears read with browser zoom — a cutlery maker's website — Breakpoint Morphing Cards example 1

① Product sheet for a pair of shears read with browser zoom — a cutlery maker's website

WhenAt 100 %, the dressmaker's shears sheet takes 524 px: visual on the left, description and two buttons on the right. The customer zooms to 125 %: the page now gives the sheet only 416 CSS pixels, so it goes back to a column, 70 px band on top. At 150 % it keeps that layout, losing nothing and never overflowing.
WhyZooming in reduces the width in CSS pixels: the sheet rearranges instead of squeezing, and “Add to basket” stays within reach.
SettingsThe mock page is enlarged with the CSS zoom property, its width divided by the same amount, as browser zoom does; − and + set it up to 175 %, and until they are touched a timer steps from 100 to 125 then 150 % every 0.6 s for the capture. At 200 % the sheet would drop under 280 px and its buttons would disappear. Steel-grey visual, rust button, line pictogram.
Three vegetable baskets side by side, the hovered one unfolds — a market gardener's site — Breakpoint Morphing Cards example 2

② Three vegetable baskets side by side, the hovered one unfolds — a market gardener's site

WhenAt rest the three baskets share the row (167 px each): band and name, price underneath. Pointer or focus on a basket widens it to 311 px: its band grows, its contents and the “Choose” and “Contents” buttons appear; the other two squeeze to 94 px.
WhyThree offers compared at a glance, and only the interesting one opens, without leaving the row.
SettingsEach root sits in a flexible, focusable column (tabindex="0", otherwise the keyboard would have nothing to reach while the buttons are hidden) whose flex-grow the page changes on hover and focus (0.18 s). Price and weight added by the page under the card. One gradient per basket.
Compatible parts for a lawnmower, the chosen part unfolds into a full card — a repair shop's site — Breakpoint Morphing Cards example 3

③ Compatible parts for a lawnmower, the chosen part unfolds into a full card — a repair shop's site

WhenFive parts are listed. The chosen one moves to the top and takes the whole row (516 px): visual on the left, description, “Order” and “Guide”. The others stay 167 px thumbnails. A click on “Air filter” opens it in turn; the spark plug goes back to a thumbnail and its pictogram shrinks.
WhyThe list works as both index and detailed card: no page to load to read a reference.
SettingsThree-column page grid; the is-on class stretches the chosen item over the entire row and places it first. A transparent button covers each thumbnail to choose it by click or keyboard (aria-pressed): that is the page's script.

How it works

The card lays three blocks on a grid: .mpc-visual (a pink band with a white pictogram), .mpc-text (an h5 and a description) and .mpc-actions (a solid button, a quiet one). In a slot under 280 px, only the band, 50 px tall, and the name show: the card fits in 87 px of height.

The root .fx-0760-root measures its own width (container: mpc-card / inline-size). At 280 px the description and both buttons arrive together, the band goes from 50 to 70 px and the pictogram from 24 to 32 px. At 420 px the grid becomes 130px 1fr over two rows: the visual takes the left column over the full height (grid-row: 1 / 3), text and buttons stack on the right, the pictogram reaches 40 px.

What is animated, precisely: the band height between 50 and 70 px and the pictogram size at each threshold, in 0.4 s. The description and buttons appearing, like the switch to two columns, are instant. On hover each button grows by 5 %. No script: the buttons have no action until you give them one.

Accessibility

  • No buttons when small: under 280 px, .mpc-actions is display: none. Neither mouse, keyboard nor screen reader can find the buttons. If buying must stay possible from a thumbnail, make the name a link.
  • Keyboard: from 280 px, Tab goes to the main button then the secondary one; each shows a 2 px pale pink outline on focus.
  • Small targets: the buttons are 22 px tall with 10.9 px text. On a touch screen, raise their padding to 9px 14px.
  • Reduced motion: the prefers-reduced-motion: reduce rule switches off every transition, including the buttons' hover growth; the three states stay the same.
  • Pictogram: decorative, hidden from screen readers with aria-hidden. The product name is an h5, to adjust to your heading outline.

Browser compatibility

CSS grid and container queries. In Chromium 149, Firefox 151 and WebKit 26.5 the buttons appear at 280 px (absent at 279) and the two columns at 420 px (a single one at 419); the band and the pictogram do animate in all three. Firefox also plays these transitions once when the page opens: the pictogram starts at 24 px before taking its size.

Chrome 105+✓ Full (measured in Chromium 149)
Firefox 110+✓ Full (measured in Firefox 151) — animation replayed on load
Safari 16+✓ Measured in WebKit 26.5; real Safari not verified
Edge 105+✓ Not verified (same engine as Chrome)
Mobile iOS 16+✓ Not verified on a device
Android Chrome 105+✓ Measured in 390 px emulation: middle state, no overflow

Without @container the card stays a thumbnail: band and name, no description and no buttons. For an audience on old browsers, display .mpc-actions in the base rule.

The code

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

index.html — structure
<div class="fx-0760-root">
  <div class="mpc-card">
    <div class="mpc-visual">
      <svg viewBox="0 0 24 24" aria-hidden="true">…</svg>
    </div>
    <div class="mpc-text">
      <h5>Product name</h5>
      <p>Description shown from 280 px</p>
    </div>
    <div class="mpc-actions">
      <button type="button" class="mpc-btn-primary">Main action</button>
      <button type="button" class="mpc-btn-secondary">Secondary action</button>
    </div>
  </div>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Thresholds (CSS — @container mpc-card (min-width: 280px) and (min-width: 420px)) 280 and 420 px Bring them closer (240 and 360 px) for cards in a tight grid.
Band height (CSS — .mpc-visual { height }) 50 px, then 70 px at 280 px 80 and 120 px if the visual is a photo; keep two pixel values so the transition plays.
Pictogram size (CSS — .mpc-visual svg) 24 → 32 → 40 px Same value at all three steps for a fixed pictogram.
Visual column (CSS — 130px 1fr in the 420 px rule) 130 px 180 px for a portrait product photo.
Colours (CSS — .mpc-visual, .mpc-btn-primary, .mpc-btn-secondary) #ec4899 → #f43f5e gradient, #db2777 button A photo goes in with background-image on .mpc-visual (cover cropping already set).
Duration (CSS — transition: .4s) 0.4 s 0.2 s for a snappier change; none also removes Firefox's load animation.

FAQ

Product Card shows a price, reveals its description from 220 px and only adds its second button at 300 px, when turning into a row; nothing in it changes size smoothly. Breakpoint Morphing Cards has no price: its two buttons arrive together at 280 px, the columns wait for 420 px, and its visual grows before your eyes at each threshold. Product Card for a dense shop, this one when the size change should be seen.
No. Two things are: the band height (50 ↔ 70 px) and the pictogram size (24, 32, 40 px). Text and buttons appear at once, and at 420 px the visual takes its place on the left without sliding — only the pictogram keeps growing.
It is intended: under 280 px wide the card keeps only the visual and the name. Lower the first threshold, or move .mpc-actions out of the @container rule to show it everywhere; two 60 px buttons fit in a 150 px thumbnail.