OnlineCBT Logo OnlineCBT
CSS Tutorial
CSS · LESSON 36

Keyframe Animations and Animation Properties

By Ratan Updated: 15 Oct 2026

Build complex multi-step custom animations using @keyframes, animation-name, duration, and iteration.

Level: Beginner to Advanced
Duration: ~60 Mins Deep-Dive

Describe several stages of one animation

@keyframes defines values at points in an animation timeline. The animation property chooses the keyframes, duration, timing and repetition. Use animation for a meaningful state or demonstration, not endless movement that competes with reading.

@keyframes reveal {
  from { opacity: 0; transform: translateY(0.5rem); }
  to { opacity: 1; transform: translateY(0); }
}
.notice { animation: reveal 220ms ease-out both; }
@media (prefers-reduced-motion: reduce) {
  .notice { animation: none; }
}

The notice moves a short distance while becoming visible. The base content must remain readable when the animation is disabled. Avoid making essential text permanently opacity:0 outside an animation that might fail to run.

Important controls

animation-iteration-count sets repetition; infinite repeats without a natural stop. animation-direction can alternate the playback direction. animation-fill-mode determines whether keyframe values apply outside the active interval; it does not mean the DOM content has changed. animation-play-state can pause a running animation.

Timing and percentages

0% and 100% represent the start and end. Intermediate percentages let you define a multi-step sequence. If multiple animations write the same property, understand their composition rather than assuming every transform combines automatically.

Usability checks

Continuous motion should have an appropriate pause/stop mechanism when needed. Do not use rapid flashing. Keep a status message available as text; a spinning icon alone cannot tell a screen-reader user what is loading or whether it failed.

Practice

  1. Add a 50% keyframe and inspect the intermediate state.
  2. Change one-shot playback to two iterations and observe fill behavior.
  3. Emulate reduced motion and verify the notice remains visible.
  4. Build a progress state with a text label and a real error state instead of an endless spinner.

📝 Live Lesson Practice

HTML/CSS JavaScript Python C++ C PHP
⌨️ Practice Inputs (लाइव इनपुट भरें) (खाली होने पर RED, भरने पर GREEN underline)
💻 Code Editor (Monaco VS Code Engine)
👀 Live Preview
Address Contact

+91 7877547686

E-mail

onlinecbtportal@gmail.com

Helpline Number

+91 7877547686


Click To Download
Get it on Google Play

ऐप डाउनलोड करने
के लिए Google Play पर
उपलब्ध है

WhatsApp Chat