CSS Zoom on Hover
Smoothly zooms an image inside its frame on hover without changing the layout.
HTML
<div class="zoom-frame">
<img alt="Sun over blue hills" width="220" height="150" src="data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 22 15%27%3E%3Crect width=%2722%27 height=%2715%27 fill=%27%236366f1%27/%3E%3Ccircle cx=%277%27 cy=%275%27 r=%273%27 fill=%27%23fde047%27/%3E%3Cpath d=%27M0 15 8 8l5 4 4-3 5 6z%27 fill=%27%230ea5e9%27/%3E%3C/svg%3E">
</div>
CSS
.zoom-frame {
overflow: hidden;
border-radius: 14px;
}
.zoom-frame img {
display: block;
width: 100%;
height: auto;
transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.zoom-frame:hover img {
transform: scale(1.08);
}
About this CSS Zoom on Hover
This CSS Zoom on Hover is 15 lines of pure CSS (0.2 KB) with no JavaScript and no dependencies. It uses transitions and transforms. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.
CSS features used
How to use this zoom on hover
- Copy the HTML and paste it where you want the element to appear.
- Copy the CSS into your stylesheet, or inside a
<style>tag. - Keep the
.zoom-frameclass name, or rename it in both places. Then tweak colors, sizes and timing to match your design. - Using React or Next.js? Change
classtoclassNamein the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).
Building with an AI tool?
“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.