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.
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



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-actionsisdisplay: 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
paddingto 9px 14px. - Reduced motion: the
prefers-reduced-motion: reducerule 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 anh5, 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.
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):
<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 / property | Default | Effect |
|---|---|---|
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
.mpc-actions out of the @container rule to show it everywhere; two 60 px buttons fit in a 150 px thumbnail.