18 / 20
All 20 in 20 Tailwind CSS Image Hover Effects
- 01Tailwind Image Hover Zoom In Card
- 02Tailwind Hover Reveal Text Over Image
- 03Tailwind E-Commerce Product Image Swap on Hover
- 04Tailwind Grid Image Blur Overlay Text Hover
- 05Tailwind Card Slide Up Caption on Hover
- 06Tailwind Grayscale to Color Image Hover
- 07Tailwind Image Color Overlay Tint on Hover
- 08Tailwind Neumorphic Image Card Hover Effect
- 09Tailwind Glassmorphism Overlay on Image Hover
- 10Tailwind Glowing Neon Border Image Hover
- 11Tailwind Image Clip-Path Transition Hover
- 12Tailwind Image Tilt 3D Perspective Hover
- 13Tailwind Shining Light Glare Image Hover
- 14Tailwind Image Split Transition Hover
- 15Tailwind Image Ripple Animation Hover
- 16Tailwind Circular Team Profile Avatar Hover
- 17Tailwind Fullscreen Background Image Hover
- 18Tailwind Masonry Gallery Zoom Hover
- 19Tailwind Image Icon Reveal Center Hover
- 20Tailwind Image Card Flip 3D Animation Hover
Tailwind Masonry Gallery Zoom Hover
Column-based masonry where the responsive column count is the whole layout: columns-2 sm:columns-3 plus break-inside-avoid on each item. The CSS version needs a media query to change column count; here it is one breakpoint prefix, which is the kind of edit this port makes trivial.
Untitled UI Pro: 5,000+ React + Tailwind CSS v4 components · from $349 one-time
Untitled UI React · Affiliate link
The code
<section class="tih-18 w-full min-h-svh bg-tih18-bg font-tih18-sans px-6 py-8" aria-label="Masonry gallery zoom hover demo">
<div class="columns-2 sm:columns-3 gap-3 w-full max-w-195 mx-auto">
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[5/7] bg-[image:url('https://picsum.photos/seed/masonry-a/600/840'),linear-gradient(150deg,oklch(0.17_0.07_310),oklch(0.35_0.18_298),oklch(0.55_0.24_295))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Cosmos</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-square bg-[image:url('https://picsum.photos/seed/masonry-b/600/600'),linear-gradient(150deg,oklch(0.2_0.04_190),oklch(0.42_0.09_165),oklch(0.7_0.15_163))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Flora</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[3/2] bg-[image:url('https://picsum.photos/seed/masonry-c/600/400'),linear-gradient(150deg,oklch(0.18_0.03_60),oklch(0.45_0.11_60),oklch(0.78_0.16_72))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Desert</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-square bg-[image:url('https://picsum.photos/seed/masonry-d/600/600'),linear-gradient(150deg,oklch(0.17_0.08_265),oklch(0.33_0.14_262),oklch(0.62_0.19_260))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Ocean</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[5/7] bg-[image:url('https://picsum.photos/seed/masonry-e/600/840'),linear-gradient(150deg,oklch(0.16_0.06_350),oklch(0.4_0.18_5),oklch(0.65_0.22_15))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Bloom</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[3/2] bg-[image:url('https://picsum.photos/seed/masonry-f/600/400'),linear-gradient(150deg,oklch(0.19_0.03_230),oklch(0.32_0.06_240),oklch(0.6_0.12_215))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Ice</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[3/2] bg-[image:url('https://picsum.photos/seed/masonry-g/600/400'),linear-gradient(150deg,oklch(0.17_0.07_285),oklch(0.31_0.14_280),oklch(0.5_0.2_275))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Mystic</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[5/7] bg-[image:url('https://picsum.photos/seed/masonry-h/600/840'),linear-gradient(150deg,oklch(0.2_0.05_150),oklch(0.35_0.09_150),oklch(0.8_0.16_145))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Forest</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-square bg-[image:url('https://picsum.photos/seed/masonry-i/600/600'),linear-gradient(150deg,oklch(0.17_0.07_310),oklch(0.35_0.18_298),oklch(0.55_0.24_295))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Stars</span></figcaption>
</figure>
</div>
</section><section class="tih-18 w-full min-h-svh bg-tih18-bg font-tih18-sans px-6 py-8" aria-label="Masonry gallery zoom hover demo">
<div class="columns-2 sm:columns-3 gap-3 w-full max-w-195 mx-auto">
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[5/7] bg-[image:url('https://picsum.photos/seed/masonry-a/600/840'),linear-gradient(150deg,oklch(0.17_0.07_310),oklch(0.35_0.18_298),oklch(0.55_0.24_295))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Cosmos</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-square bg-[image:url('https://picsum.photos/seed/masonry-b/600/600'),linear-gradient(150deg,oklch(0.2_0.04_190),oklch(0.42_0.09_165),oklch(0.7_0.15_163))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Flora</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[3/2] bg-[image:url('https://picsum.photos/seed/masonry-c/600/400'),linear-gradient(150deg,oklch(0.18_0.03_60),oklch(0.45_0.11_60),oklch(0.78_0.16_72))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Desert</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-square bg-[image:url('https://picsum.photos/seed/masonry-d/600/600'),linear-gradient(150deg,oklch(0.17_0.08_265),oklch(0.33_0.14_262),oklch(0.62_0.19_260))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Ocean</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[5/7] bg-[image:url('https://picsum.photos/seed/masonry-e/600/840'),linear-gradient(150deg,oklch(0.16_0.06_350),oklch(0.4_0.18_5),oklch(0.65_0.22_15))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Bloom</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[3/2] bg-[image:url('https://picsum.photos/seed/masonry-f/600/400'),linear-gradient(150deg,oklch(0.19_0.03_230),oklch(0.32_0.06_240),oklch(0.6_0.12_215))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Ice</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[3/2] bg-[image:url('https://picsum.photos/seed/masonry-g/600/400'),linear-gradient(150deg,oklch(0.17_0.07_285),oklch(0.31_0.14_280),oklch(0.5_0.2_275))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Mystic</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[5/7] bg-[image:url('https://picsum.photos/seed/masonry-h/600/840'),linear-gradient(150deg,oklch(0.2_0.05_150),oklch(0.35_0.09_150),oklch(0.8_0.16_145))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Forest</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-square bg-[image:url('https://picsum.photos/seed/masonry-i/600/600'),linear-gradient(150deg,oklch(0.17_0.07_310),oklch(0.35_0.18_298),oklch(0.55_0.24_295))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Stars</span></figcaption>
</figure>
</div>
</section>@import "tailwindcss";
@theme {
--color-tih18-bg: #08080c;
--color-tih18-bg: oklch(0.12 0.008 285);
--color-tih18-text: #f1f5f9;
--color-tih18-text: oklch(0.96 0.005 250);
--color-tih18-muted: #64748b;
--color-tih18-muted: oklch(0.58 0.035 255);
--color-tih18-acc: #f43f5e;
--color-tih18-acc: oklch(0.6 0.22 15);
--font-tih18-sans: 'Space Grotesk', system-ui, sans-serif;
--ease-tih18: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's
w-full min-h-svh, so the stage is correctly sized before the browser build compiles. */
.tih-18 {
width: 100%;
min-height: 100svh;
}
.tih-18 ::selection {
background: oklch(0.6 0.22 15);
color: #fff;
}@import "tailwindcss";
@theme {
--color-tih18-bg: #08080c;
--color-tih18-bg: oklch(0.12 0.008 285);
--color-tih18-text: #f1f5f9;
--color-tih18-text: oklch(0.96 0.005 250);
--color-tih18-muted: #64748b;
--color-tih18-muted: oklch(0.58 0.035 255);
--color-tih18-acc: #f43f5e;
--color-tih18-acc: oklch(0.6 0.22 15);
--font-tih18-sans: 'Space Grotesk', system-ui, sans-serif;
--ease-tih18: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's
w-full min-h-svh, so the stage is correctly sized before the browser build compiles. */
.tih-18 {
width: 100%;
min-height: 100svh;
}
.tih-18 ::selection {
background: oklch(0.6 0.22 15);
color: #fff;
}Setup — do this once per project
Skip this if your project already runs Tailwind v4.
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>Compiles in the browser — perfect for a CodePen or a quick test, not for production.
npm install tailwindcss @tailwindcss/vite
npm install tailwindcss @tailwindcss/vite// vite.config.js ("type": "module" in package.json)
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [tailwindcss()],
})// vite.config.js ("type": "module" in package.json)
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [tailwindcss()],
})Any v4 setup works — Vite, PostCSS or the CLI. Nothing in this demo is bundler-specific.
@import "tailwindcss";
@theme {
--color-tih18-bg: #08080c;
--color-tih18-bg: oklch(0.12 0.008 285);
--color-tih18-text: #f1f5f9;
--color-tih18-text: oklch(0.96 0.005 250);
--color-tih18-muted: #64748b;
--color-tih18-muted: oklch(0.58 0.035 255);
--color-tih18-acc: #f43f5e;
--color-tih18-acc: oklch(0.6 0.22 15);
--font-tih18-sans: 'Space Grotesk', system-ui, sans-serif;
--ease-tih18: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's
w-full min-h-svh, so the stage is correctly sized before the browser build compiles. */
.tih-18 {
width: 100%;
min-height: 100svh;
}
.tih-18 ::selection {
background: oklch(0.6 0.22 15);
color: #fff;
}@import "tailwindcss";
@theme {
--color-tih18-bg: #08080c;
--color-tih18-bg: oklch(0.12 0.008 285);
--color-tih18-text: #f1f5f9;
--color-tih18-text: oklch(0.96 0.005 250);
--color-tih18-muted: #64748b;
--color-tih18-muted: oklch(0.58 0.035 255);
--color-tih18-acc: #f43f5e;
--color-tih18-acc: oklch(0.6 0.22 15);
--font-tih18-sans: 'Space Grotesk', system-ui, sans-serif;
--ease-tih18: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's
w-full min-h-svh, so the stage is correctly sized before the browser build compiles. */
.tih-18 {
width: 100%;
min-height: 100svh;
}
.tih-18 ::selection {
background: oklch(0.6 0.22 15);
color: #fff;
}<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap">What changed in the port
Which parts became utilities, which stayed CSS, and why.
columns: 3plus a media query becomescolumns-2 sm:columns-3— the responsive column count the CSS version lists as a customization is a one-token edit here.- The
padding-top: 140%ratio hack is replaced byaspect-[5/7]and friends, which is both the modern property and a readable ratio. - Eight
__img--xphoto rules become eightbg-[image:url(…),linear-gradient(…)]utilities, each next to the card it paints. - Semantic markup came along for free:
<figure>and<figcaption>cost nothing in a utility port and make the gallery legible to assistive tech. break-inside-avoidis a plain utility on each item, which puts the fragility of column layout where you can see it rather than in a shared rule.motion-reduce:opacity-100on the caption is load-bearing: the tag names live in the overlay, and with no motion they must simply be shown.
Here's a working CSS demo from CodeFronts. Use it as-is or adapt to your framework. All classes are scoped under a unique prefix so the code won't collide with your existing styles. MIT licensed.
Demo: Tailwind Masonry Gallery Zoom Hover
Source: https://codefronts.com/motion/tailwind-css-image-hover-effects/tailwind-masonry-gallery-zoom-hover/
Column-based masonry where the responsive column count is the whole layout: columns-2 sm:columns-3 plus break-inside-avoid on each item. The CSS version needs a media query to change column count; here it is one breakpoint prefix, which is the kind of edit this port makes trivial.
## HTML
```html
<section class="tih-18 w-full min-h-svh bg-tih18-bg font-tih18-sans px-6 py-8" aria-label="Masonry gallery zoom hover demo">
<div class="columns-2 sm:columns-3 gap-3 w-full max-w-195 mx-auto">
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[5/7] bg-[image:url('https://picsum.photos/seed/masonry-a/600/840'),linear-gradient(150deg,oklch(0.17_0.07_310),oklch(0.35_0.18_298),oklch(0.55_0.24_295))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Cosmos</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-square bg-[image:url('https://picsum.photos/seed/masonry-b/600/600'),linear-gradient(150deg,oklch(0.2_0.04_190),oklch(0.42_0.09_165),oklch(0.7_0.15_163))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Flora</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[3/2] bg-[image:url('https://picsum.photos/seed/masonry-c/600/400'),linear-gradient(150deg,oklch(0.18_0.03_60),oklch(0.45_0.11_60),oklch(0.78_0.16_72))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Desert</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-square bg-[image:url('https://picsum.photos/seed/masonry-d/600/600'),linear-gradient(150deg,oklch(0.17_0.08_265),oklch(0.33_0.14_262),oklch(0.62_0.19_260))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Ocean</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[5/7] bg-[image:url('https://picsum.photos/seed/masonry-e/600/840'),linear-gradient(150deg,oklch(0.16_0.06_350),oklch(0.4_0.18_5),oklch(0.65_0.22_15))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Bloom</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[3/2] bg-[image:url('https://picsum.photos/seed/masonry-f/600/400'),linear-gradient(150deg,oklch(0.19_0.03_230),oklch(0.32_0.06_240),oklch(0.6_0.12_215))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Ice</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[3/2] bg-[image:url('https://picsum.photos/seed/masonry-g/600/400'),linear-gradient(150deg,oklch(0.17_0.07_285),oklch(0.31_0.14_280),oklch(0.5_0.2_275))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Mystic</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[5/7] bg-[image:url('https://picsum.photos/seed/masonry-h/600/840'),linear-gradient(150deg,oklch(0.2_0.05_150),oklch(0.35_0.09_150),oklch(0.8_0.16_145))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Forest</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-square bg-[image:url('https://picsum.photos/seed/masonry-i/600/600'),linear-gradient(150deg,oklch(0.17_0.07_310),oklch(0.35_0.18_298),oklch(0.55_0.24_295))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Stars</span></figcaption>
</figure>
</div>
</section>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-tih18-bg: #08080c;
--color-tih18-bg: oklch(0.12 0.008 285);
--color-tih18-text: #f1f5f9;
--color-tih18-text: oklch(0.96 0.005 250);
--color-tih18-muted: #64748b;
--color-tih18-muted: oklch(0.58 0.035 255);
--color-tih18-acc: #f43f5e;
--color-tih18-acc: oklch(0.6 0.22 15);
--font-tih18-sans: 'Space Grotesk', system-ui, sans-serif;
--ease-tih18: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's
w-full min-h-svh, so the stage is correctly sized before the browser build compiles. */
.tih-18 {
width: 100%;
min-height: 100svh;
}
.tih-18 ::selection {
background: oklch(0.6 0.22 15);
color: #fff;
}
```Here's a working CSS demo from CodeFronts. Use it as-is or adapt to your framework. All classes are scoped under a unique prefix so the code won't collide with your existing styles. MIT licensed.
Demo: Tailwind Masonry Gallery Zoom Hover
Source: https://codefronts.com/motion/tailwind-css-image-hover-effects/tailwind-masonry-gallery-zoom-hover/
Column-based masonry where the responsive column count is the whole layout: columns-2 sm:columns-3 plus break-inside-avoid on each item. The CSS version needs a media query to change column count; here it is one breakpoint prefix, which is the kind of edit this port makes trivial.
## HTML
```html
<section class="tih-18 w-full min-h-svh bg-tih18-bg font-tih18-sans px-6 py-8" aria-label="Masonry gallery zoom hover demo">
<div class="columns-2 sm:columns-3 gap-3 w-full max-w-195 mx-auto">
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[5/7] bg-[image:url('https://picsum.photos/seed/masonry-a/600/840'),linear-gradient(150deg,oklch(0.17_0.07_310),oklch(0.35_0.18_298),oklch(0.55_0.24_295))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Cosmos</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-square bg-[image:url('https://picsum.photos/seed/masonry-b/600/600'),linear-gradient(150deg,oklch(0.2_0.04_190),oklch(0.42_0.09_165),oklch(0.7_0.15_163))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Flora</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[3/2] bg-[image:url('https://picsum.photos/seed/masonry-c/600/400'),linear-gradient(150deg,oklch(0.18_0.03_60),oklch(0.45_0.11_60),oklch(0.78_0.16_72))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Desert</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-square bg-[image:url('https://picsum.photos/seed/masonry-d/600/600'),linear-gradient(150deg,oklch(0.17_0.08_265),oklch(0.33_0.14_262),oklch(0.62_0.19_260))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Ocean</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[5/7] bg-[image:url('https://picsum.photos/seed/masonry-e/600/840'),linear-gradient(150deg,oklch(0.16_0.06_350),oklch(0.4_0.18_5),oklch(0.65_0.22_15))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Bloom</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[3/2] bg-[image:url('https://picsum.photos/seed/masonry-f/600/400'),linear-gradient(150deg,oklch(0.19_0.03_230),oklch(0.32_0.06_240),oklch(0.6_0.12_215))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Ice</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[3/2] bg-[image:url('https://picsum.photos/seed/masonry-g/600/400'),linear-gradient(150deg,oklch(0.17_0.07_285),oklch(0.31_0.14_280),oklch(0.5_0.2_275))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Mystic</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-[5/7] bg-[image:url('https://picsum.photos/seed/masonry-h/600/840'),linear-gradient(150deg,oklch(0.2_0.05_150),oklch(0.35_0.09_150),oklch(0.8_0.16_145))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Forest</span></figcaption>
</figure>
<figure class="group relative block mb-3 break-inside-avoid overflow-hidden rounded-[10px]">
<div class="aspect-square bg-[image:url('https://picsum.photos/seed/masonry-i/600/600'),linear-gradient(150deg,oklch(0.17_0.07_310),oklch(0.35_0.18_298),oklch(0.55_0.24_295))] bg-cover bg-center transition-transform duration-400 ease-tih18 group-hover:scale-108 motion-reduce:transition-none motion-reduce:group-hover:scale-100"></div>
<figcaption class="absolute inset-0 flex items-end p-2.5 bg-linear-[to_top,oklch(0_0_0/0.7),transparent_60%] opacity-0 transition-opacity duration-400 ease-tih18 group-hover:opacity-100 motion-reduce:transition-none motion-reduce:opacity-100"><span class="px-1.5 py-0.5 rounded text-[10px] font-bold text-white bg-[oklch(0.6_0.22_15/0.7)]">Stars</span></figcaption>
</figure>
</div>
</section>
```
## CSS
```css
@import "tailwindcss";
@theme {
--color-tih18-bg: #08080c;
--color-tih18-bg: oklch(0.12 0.008 285);
--color-tih18-text: #f1f5f9;
--color-tih18-text: oklch(0.96 0.005 250);
--color-tih18-muted: #64748b;
--color-tih18-muted: oklch(0.58 0.035 255);
--color-tih18-acc: #f43f5e;
--color-tih18-acc: oklch(0.6 0.22 15);
--font-tih18-sans: 'Space Grotesk', system-ui, sans-serif;
--ease-tih18: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
/* Root rule: the full-bleed contract, stated in CSS as well as in the markup's
w-full min-h-svh, so the stage is correctly sized before the browser build compiles. */
.tih-18 {
width: 100%;
min-height: 100svh;
}
.tih-18 ::selection {
background: oklch(0.6 0.22 15);
color: #fff;
}
```How this works
Masonry is two utilities. columns-2 sm:columns-3 on the container and break-inside-avoid on each item. The browser distributes items top-to-bottom per column; nothing measures anything.
Aspect ratios, not padding hacks. The CSS version sizes items with padding-top: 140%. The port uses aspect-[5/7], aspect-square and aspect-[3/2] — the modern equivalent, and readable as a ratio rather than as a percentage of an unrelated dimension.
The zoom is contained twice over. The item clips it (overflow-hidden), and scale does not participate in layout, so a hovered card cannot push its column. That is what makes hover-zoom safe inside a fragile layout mode.
Make it yours
- Column count: the
columns-*pair — addlg:columns-4for wide screens. - Gutters:
gap-3on the container sets the column gap; itemmb-3sets the vertical rhythm. - Zoom:
group-hover:scale-108, or addgroup-hover:brightness-110. - Swap the placeholder photos in the
bg-[image:url(…)]utilities; keep the gradient as the fallback layer. - For true height-sorted masonry you still need JS — columns fill top-to-bottom by design.
Gotchas — read before shipping
- CSS columns do not reorder by height. If the visual balance matters more than the DOM order, this is not the layout mode — and no utility changes that.
- An item taller than its column can overflow in some engines; cap it with
max-h-*if heights are unpredictable. - Firefox can show a 1px seam between columns with clipped children — a negative margin or a column rule masks it.
break-inside-avoidbelongs on the item, not on the container. On the container it does nothing and the cards fragment.- Overlay reveals in a masonry grid are hover-only by nature; the tag text is inside the overlay, so
motion-reduce:opacity-100matters more here than it looks. - The browser CDN build compiles in the page and is for prototyping only. Ship the CLI or a plugin build.
Browser support
| Chrome | Safari | Firefox | Edge |
|---|---|---|---|
| 111+ | 16.4+ | 128+ | 111+ |
CSS multi-column is broadly supported; column fill behaviour differs slightly between engines, which is inherent to the technique rather than to Tailwind.