Keep the last frame of a CSS banner

Stop a banner’s offer from disappearing when a one-shot animation ends.

Multi-format design2 min read

“Free delivery” fades in, then vanishes the instant the banner stops moving. The animation reached full opacity, but the element’s underlying opacity is still zero. Once the animation ends, the underlying style takes over unless you keep the final frame.

Compare the banner after two seconds

Open the working comparison. With normal motion enabled, both copies fade in over two seconds. The first disappears at the end. The second stays visible. Reload to replay or turn on reduced motion to check the static result.

CSS
.offer { opacity: 1; }

@media (prefers-reduced-motion: no-preference) {
  .offer { opacity: 0; animation: reveal 2s ease-out forwards; }
}

@keyframes reveal {
  to { opacity: 1; }
}

With the default animation-fill-mode: none, the animation stops supplying opacity after it finishes, so the normal-motion style takes over again at 0. With forwards, the value at the end of the active interval stays applied. Here that’s 1. In a reversed or alternating animation, verify which keyframe actually plays last. CSS Animations specification.

Verify the still frame and the static fallback

Open the exported banner at the final dimensions. Watch it from load to the end and check that the offer still reads after three seconds. Turn on reduced motion and reload. The offer should be visible immediately, including its terms if they are in the same layer. If a platform wraps or restarts the ad, repeat the check in its own preview.

This example deliberately starts at zero under normal motion to expose the fill-mode difference. If you only need a fade-in, a simpler production choice is to leave the underlying opacity at 1 for everyone and set from { opacity: 0; } in the keyframes. The final static style is then correct even when the animation is removed.

Marketing workflow
All guides
Keep the last frame of a CSS banner | Formatry Media — Formatry