How to Create the Ken Burns Pan & Zoom Effect in Pure CSS
The Ken Burns effect imparts slow, cinematic panning and zooming onto still photographs. In pure CSS, wrap the image in an overflow: hidden container and animate transform: scale(1.15) translate(x, y) over a 15–25 second duration with animation: kenBurns 20s ease-out infinite alternate. Setting transform-origin to specific focal coordinates (e.g. top left or bottom right) steers the viewer's gaze naturally across the image.
Step 1: Container Setup: overflow: hidden & Fixed Aspect Ratio
To prevent zooming images from spilling outside their layout boundaries, wrap the target image inside a fixed or responsive container styled with overflow: hidden.
<div class="ken-burns-frame">
<img src="architectural-hero.jpg" alt="Cinematic hero photo" class="ken-burns-img">
</div>
<style>
.ken-burns-frame {
position: relative;
width: 100%;
height: 480px;
overflow: hidden;
border-radius: 12px;
}
</style>
Step 2: Hardware-Accelerated Keyframes: scale() & translate()
Never animate top, left, width, or height, as these trigger costly browser reflows. Animate exclusively with transform: scale() translate3d() to ensure the GPU handles all motion on composite layers.
.ken-burns-img {
width: 100%;
height: 100%;
object-fit: cover;
will-change: transform;
animation: kenBurnsPanZoom 20s ease-in-out infinite alternate;
}
@keyframes kenBurnsPanZoom {
0% {
transform: scale(1.0) translate3d(0, 0, 0);
transform-origin: center center;
}
100% {
transform: scale(1.18) translate3d(-20px, -15px, 0);
transform-origin: top left;
}
}
Step 3: Steering Focal Direction with transform-origin
Different photographs require different focal storytelling: portraits benefit from zooming toward the eyes (top center), while landscapes often pan from horizon (bottom left) to sky (top right).
/* Variation A: Zooming In on Subject */
.zoom-in {
animation: zoomIn 18s ease-out infinite alternate;
transform-origin: 65% 35%; /* Face coordinates */
}
/* Variation B: Slow Pan Across Landscape */
.pan-right {
animation: panRight 22s ease-in-out infinite alternate;
}
@keyframes panRight {
0% { transform: scale(1.12) translate3d(-3%, 0, 0); }
100% { transform: scale(1.12) translate3d(3%, 0, 0); }
}
Step 4: Cross-Fading Multi-Slide Hero Galleries
Create documentary-style multi-image hero banners by layering multiple images with staggered animation delays and smooth cross-fading opacity keyframes.
.slide-1 { animation: slideFade 16s infinite 0s; }
.slide-2 { animation: slideFade 16s infinite 8s; }
@keyframes slideFade {
0% { opacity: 0; transform: scale(1.0); }
15% { opacity: 1; }
85% { opacity: 1; }
100% { opacity: 0; transform: scale(1.15) translate3d(-10px, -10px, 0); }
}
Next-Level Addons: Elevating Your Implementation
Take this technique further by combining it with complementary design token studios and animation tools:
When building high-performance UI animations or particle systems, my golden rule is: never calculate layout triggers (like getBoundingClientRect() or offsetHeight) inside animation loops. Read measurements once upfront and use CSS transforms or Canvas for buttery 60fps.
Frequently Asked Questions
Practical answers to common implementation questions, browser quirks, and performance tips.
Who was Ken Burns and why is this effect named after him?
Ken Burns is an acclaimed American documentary filmmaker (known for *The Civil War* and *Baseball*). To bring archival still photography to life on television, he slowly panned and zoomed his camera over historical photographs to guide the viewer's narrative focus.
Why should I avoid using scale values greater than 1.25 in CSS?
Scaling a raster image beyond 1.25x (125%) can cause visible pixelation or softness. A scale range of `1.05` to `1.20` provides ample cinematic movement while keeping photography crisp on high-DPI displays.
How does will-change: transform optimize slow Ken Burns animations?
Declaring `will-change: transform` prompts the browser engine to promote the image to its own dedicated GPU composite layer ahead of time, preventing sub-pixel stutter during slow 20-second animations.
How should I handle prefers-reduced-motion for the Ken Burns effect?
Slow continuous movement can cause nausea for vestibular disorder users. Always include `@media (prefers-reduced-motion: reduce) { .ken-burns-img { animation: none; transform: none; } }`.
Can Ken Burns animations cause high battery consumption on mobile devices?
Because `transform` is animated on the GPU rather than repainting the DOM with CPU cycles, battery consumption is minimal compared to JavaScript-driven animation loops.