CSS Ken Burns Effect
A slow, cinematic zoom-and-pan on a hero image, looping back and forth inside a cropped frame.
HTML
<div class="ken-burns">
<img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 40'%3E%3Cdefs%3E%3ClinearGradient id='s' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23f472b6'/%3E%3Cstop offset='1' stop-color='%23fdba74'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='60' height='40' fill='url(%23s)'/%3E%3Ccircle cx='42' cy='15' r='7' fill='%23fef08a'/%3E%3Cpath d='M0 40V26l12-8 10 7 9-5 14 9 15-6v17z' fill='%237c3aed'/%3E%3Cpath d='M0 40v-8l16-5 12 4 14-6 18 6v9z' fill='%234c1d95'/%3E%3C/svg%3E" alt="Purple hills under a pink sunset" width="260" height="160">
</div>
CSS
.ken-burns {
width: 260px;
height: 160px;
overflow: hidden;
border-radius: 14px;
}
.ken-burns img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
transform-origin: 70% 40%;
animation: ken-burns-move 14s ease-in-out infinite alternate;
}
@keyframes ken-burns-move {
from {
transform: scale(1) translate(0, 0);
}
to {
transform: scale(1.3) translate(-4%, 3%);
}
}
@media (prefers-reduced-motion: reduce) {
.ken-burns img {
animation: none;
}
}
About this CSS Ken Burns Effect
This CSS Ken Burns Effect is 31 lines of pure CSS (0.5 KB) with no JavaScript and no dependencies. It uses keyframe animations, transforms and reduced-motion support. 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 ken burns effect
- 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
.ken-burnsclass 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.