Ken Burns Effect Css
StyleFrame Team8 min read
The Ken Burns effect in CSS is a slow transform animation, a gradual scale() combined with a small translate(), applied to an image inside a container set to overflow: hidden. Run it with @keyframes over 10 to 20 seconds, animate only transform for smooth playback, and add a prefers-reduced-motion fallback. The same move in After Effects is two keyframed properties, Scale and Position, on a layer larger than the comp frame.
The Minimal CSS Ken Burns Effect
You need two elements: a fixed-size frame that crops, and an image that moves inside it.
Each part does a specific job:
overflow: hiddenon the frame is the crop. Without it, the scaled image spills over neighboring content.object-fit: coverfills the frame without distortion, whatever the image's aspect ratio.transform-originsets the zoom anchor. It is the CSS equivalent of the anchor point in After Effects, and it decides whether the move feels like a push into the center or a drift toward a subject.alternatewithinfinitemakes the move ping-pong. For a one-shot hero reveal, dropinfinite, useforwards, and let it settle.prefers-reduced-motiondisables large-area motion for users who have asked their device to minimize animation. Large moving backgrounds are a known trigger for vestibular discomfort, so treat this as part of the effect, not an afterthought.
Pan and Zoom Math That Avoids Exposed Edges
The most common bug is a pan that slides the image far enough to reveal empty frame. The fix is arithmetic, not trial and error.
With the origin at center and a scale of s, the image overhangs the frame by (s − 1) / 2 of its size on each side. At scale(1.2), that is 10% per side, so you can pan up to roughly 10% of the width horizontally and 10% of the height vertically before an edge shows. If the origin isn't centered, the overhang is lopsided, so recalculate.
Transform order also matters. In transform: scale(1.2) translate(-3%, 2%), the translate is applied in the scaled coordinate space, so the visible shift is multiplied by the scale. Reverse the order and the same numbers produce a different move. Keep the order consistent between keyframes, or the browser will interpolate in unexpected ways.
For art-directed moves, define the start and end as custom properties and reuse one keyframe set:
Now each slide in a gallery can have its own framing: a push toward a face, a drift across a landscape, a pull-out from a detail.
Fixing Jerky Motion on Long Animations
Slow moves expose rendering problems that fast ones hide. If your Ken Burns effect stutters or crawls in visible steps, check these in order.
Animate transform, not layout or positioning properties. A common developer complaint is that animating object-position produces choppy results over long durations, especially at 40 to 60 seconds. Transforms are generally composited on the GPU, while properties that affect painting or layout are not. Replace object-position, top/left, and width/height animations with translate and scale.
Give the image resolution headroom. The image gets scaled up, so a source at exactly the display size will soften. A rough rule: source width ≥ display width × maximum scale × device pixel ratio. A 1920-pixel-wide hero scaled to 1.2 on a 2x display wants a source of about 4600 pixels wide. Using a larger source also means moving by fractions of a pixel is less visible.
Choose easing deliberately. linear can feel mechanical over a short move but hides acceleration on very long ones. ease-in-out mimics a camera operator settling in. For a more refined feel, use a custom cubic-bezier() with a gentle start and a long tail.
Use will-change: transform sparingly. It promotes the element to its own layer and can help, but applying it to dozens of images in a gallery can cost memory. Apply it only to the active slide.
Handle mixed aspect ratios. Square, portrait, and landscape images in the same component behave differently under object-fit: cover, because the cover crop already hides part of the image. Keep your pan within the overhang for the narrowest case, or set the pan direction per orientation with a class or custom properties.
Sequencing Multiple Images
A single moving image is a hero banner. A slideshow needs timing. The simplest approach is a stacked set of slides with staggered animation-delay values and an opacity cross-fade keyframe, so each image fades in while its pan is already underway. Starting the move before the image is fully visible avoids the "dead" frame where the image appears and then begins to move.
For anything beyond a few slides, a small amount of JavaScript to toggle an is-active class is easier to maintain than an intricate delay chain. It also lets you pause off-screen slides, which saves rendering work.
When CSS Is the Wrong Tool
CSS is the right choice when the effect needs to live in a web page, respond to the viewport, and stay lightweight. It is the wrong choice when you need a deliverable.
Browsers resample images in their own way, you can't control motion blur or output color management, and you can't hand a client a frame-accurate file. If the move is part of a video, build it in your editor or compositor.
The Same Move in After Effects and Premiere Pro
The Ken Burns effect translates directly into timeline tools:
- Place the image in a comp, or scale it to cover the frame with Fit to Comp plus a margin.
- Set the Anchor Point where you want the zoom to originate. This is your
transform-origin. - Keyframe Scale and Position between the start and end framings.
- Apply Easy Ease or tune the speed graph for the settle. The Graph Editor gives you far finer control over acceleration than a
cubic-bezier()string. - For the crop, the comp bounds do the job of
overflow: hidden.
In Premiere Pro, the same move uses the Motion effect's Scale and Position with ease handles. If the image has a high-resolution source, enable continuous rasterization where appropriate, or precompose, so scaling stays sharp.
Two things editors tend to add that CSS rarely does: subtle motion blur on faster moves, and a very slight rotation or handheld drift to avoid a sterile look. Both are easy in a timeline and awkward in CSS.
Beyond Flat Pan and Zoom: Adding Depth
A classic Ken Burns move treats the photograph as a flat card. It tells the viewer where to look, but it can't reveal what's behind the subject. When a project needs parallax, a camera that actually travels, or a still that becomes a shot, the usual route is manual: cut out layers, rebuild backgrounds, place them in 3D space in After Effects or Nuke, and animate a camera.
Styleframe is an AI video and motion tool built for that kind of artist-directed work, and it can take over some of the groundwork while you stay in control of the result. A few of its tools map directly to this problem:
- 2D-to-3D converts a still into a 3D representation, which is useful for camera moves with parallax rather than a flat scale.
- Frames-to-Video is keyframe-driven. You supply start and end frames, and the motion is generated between them, so you define the framing instead of accepting a random result.
- Remove Background isolates a subject so you can layer it separately in your compositor.
- 4K Upscale adds resolution headroom to a source image before you push into it.
- Restyle and Ink-and-Paint apply reference-driven style transfer if the still needs to match a particular look before it's animated.
Generations are driven by reference images, video clips, and keyframes rather than a one-click black box, and iteration is non-destructive, so you can revise a framing without losing earlier takes. Output is meant to fit into a normal After Effects or Nuke pipeline. You still do your final compositing, color, and finishing where you already do.
Whether this is worth doing depends on the shot. If the brief is a gentle push-in on an archival photo, a keyframed scale is faster and more honest. If the brief is a camera moving through a photograph, depth tools earn their place.
Quick Reference Checklist
- Wrap the image in a fixed-ratio container with
overflow: hidden. - Animate only
transform(scaleandtranslate). - Keep pan distance within the overhang:
(scale − 1) / 2per side from a centered origin. - Use a source image at least display width × max scale × pixel ratio.
- Pick easing intentionally; avoid defaults for long moves.
- Add
@media (prefers-reduced-motion: reduce)to disable the animation. - For broadcast, social, or client video deliverables, build the move in After Effects or Premiere Pro instead.
- For moves that need parallax or true camera depth, consider a depth workflow and composite the results in your usual pipeline.
The CSS version is a few lines of code, but the craft is in the details: the overhang math, the easing, the resolution of the source. Get those right and a static image reads as a camera move, in the browser or on the timeline.