Course contentsShow
← Web Development
Lesson 518 of 2,9829. CSS Transitions and AnimationsFree lesson

Multiple Properties in Keyframes

Animate multiple CSS properties simultaneously within a single keyframe definition.

Multiple Properties in Keyframes

You'll learn how to animate several CSS properties at once inside a single @keyframes rule, creating rich, coordinated animations.

What This Means

Just as you can transition multiple properties simultaneously (as you learned in lesson 508), you can also animate multiple CSS properties together within the same keyframe definition. Instead of writing separate @keyframes for each property, you combine them at each percentage point to create synchronized, multi-dimensional animations.

The Core Concept

When you define a keyframe step (like 0%, 50%, or 100%), you can list as many CSS properties as you want inside those curly braces. They'll all animate together, coordinated perfectly in time.

@keyframes slideAndFade {
  from {
    opacity: 0;
    transform: translateX(-100px);
    background-color: red;
  }
  
  to {
    opacity: 1;
    transform: translateX(0);
    background-color: blue;
  }
}

In this example, three properties animate in sync: the element fades in while sliding from left to right and changing color—all within one animation.

Why This Matters

Animating multiple properties creates richer, more polished effects. A button might grow larger while changing color. A modal might fade in while scaling up from the center. These coordinated changes feel more natural and professional than animating properties separately.

You can also vary properties at different keyframe percentages:

@keyframes complexMove {
  0% { transform: translateX(0); opacity: 1; }
  50% { transform: translateX(100px); opacity: 0.5; }
  100% { transform: translateX(0); opacity: 1; }
}

Key Takeaway: You can animate as many CSS properties as needed within a single @keyframes definition, creating sophisticated, synchronized animations where multiple visual changes happen together at precisely coordinated moments.