Protected Learning Content

AICPE Gurukul content is created for learning purposes. Printing, copying and unauthorized reuse are restricted.

AICPE Learning Hub HTML with CSS
Chapter 22
CSS Transitions & Animations
Chapter 22 | Motion Effects

CSS Transitions & Animations

Transitions and animations make a webpage feel smooth, interactive and premium. In this chapter, you will learn hover effects, transform, keyframes and animation properties.

transition

Smoothly changes CSS property values.

transform

Moves, scales, rotates or skews elements.

@keyframes

Defines steps of an animation.

animation

Runs repeated or timed motion effects.

Learning Objectives

After This Chapter, You Will Understand

This chapter teaches smooth and professional motion effects for webpages.

Transitions

Create smooth changes on hover and focus.

Transform

Move, scale and rotate webpage elements.

Keyframes

Define animation steps from start to end.

Animation

Run automatic motion effects on elements.

Motion Meaning

Why Use Transitions and Animations?

Motion effects make interactions smoother and help guide user attention.

1 Simple Meaning

A transition creates a smooth change between two states, such as normal button and hover button. An animation runs through a sequence of styles using keyframes.

Difference: Transition usually needs a trigger like hover. Animation can run automatically using keyframes.
Professional Tip: Use motion subtly. Smooth effects improve design, but too many animations can distract users.

2 Common Uses

  • Button hover effects
  • Card lift effects
  • Menu opening effects
  • Loading indicators
  • Attention-grabbing badges
  • Hero section movement
CSS Transitions

transition Property

The transition property makes style changes smooth instead of sudden.

3 Basic Syntax

.button {
  background: #06285f;
  transition: all 0.3s ease;
}

.button:hover {
  background: #ff7a1a;
}

Hover the Button

The button changes color, moves up and gets a shadow smoothly.

Transition Part Meaning Example
Property Which CSS property should animate background, transform, all
Duration How long the transition takes 0.3s, 500ms
Timing Function Speed style of transition ease, linear, ease-in-out
Delay Wait time before transition starts 0.2s
CSS Transform

Move, Scale and Rotate Elements

The transform property changes the shape or position of an element visually.

translate()

transform: translateY(-6px);

scale()

Hover
transform: scale(1.12);

rotate()

Hover
transform: rotate(10deg);
Quick Memory: translate moves, scale resizes, rotate turns, skew tilts.
Keyframes

@keyframes Rule

Keyframes define the steps of an animation from start to end.

4 Keyframes Syntax

@keyframes floatBox {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
  100% {
    transform: translateY(0);
  }
}

Floating Animation

Float

This animation moves the element up and down repeatedly.

CSS Animation

Animation Properties

Animation properties connect an element with keyframes and control timing.

Property Use Example
animation-name Name of keyframes floatBox
animation-duration How long one animation cycle takes 2s
animation-timing-function Speed style ease-in-out
animation-iteration-count How many times animation runs infinite, 3
animation-direction Direction of animation normal, alternate

Float

Float
animation: floatBox 2s ease-in-out infinite;

Pulse

Pulse
animation: pulseBox 1.6s ease-in-out infinite;

Slide

Slide
animation: slideBox 1.8s ease-in-out infinite alternate;
Try It Yourself

Practice Transitions and Animations

Edit transition, transform and animation values to see the effect.

HTML + CSS Code Edit and run
Output Preview Browser result
Practice Task: Change pulse duration to 3s, button scale to 1.15 and card hover movement to -14px.
Common Mistakes

Mistakes Students Should Avoid

Animations should make the user experience better, not confusing or heavy.

Wrong Habits

  • Adding too many animations on one page
  • Using very fast or distracting movement
  • Animating layout-heavy properties unnecessarily
  • Forgetting transition duration
  • Using hover-only effects for important information

Correct Habits

  • Use subtle motion for premium feel
  • Prefer transform and opacity for smooth effects
  • Keep duration comfortable
  • Use animations to guide attention
  • Keep website speed and accessibility in mind
Remember: The best animation is smooth, purposeful and not distracting.
Quick Quiz

Test Your Understanding

Select the correct answers and check your score.

1. Which property creates smooth change between styles?

transition creates smooth changes between CSS states.

2. Which property can scale, rotate or move an element?

transform can move, scale, rotate or skew elements.

3. Which rule defines animation steps?

@keyframes defines the steps of a CSS animation.

4. Which animation value makes animation repeat forever?

infinite repeats the animation continuously.

5. Which properties are usually smoother to animate?

transform and opacity are generally smoother for animations.
Quick Revision

Remember These Points

Revise these before moving to Chapter 23.

Transition

Smoothly changes CSS values between two states.

Hover Effect

Applies style when user points over an element.

Transform

Moves, scales, rotates or skews elements.

Keyframes

Defines animation steps from start to end.

Animation

Runs motion effects using keyframes.

Best Practice

Use subtle motion and avoid distracting animations.