CHAPTER 10
Beginner
CSS Transitions, Transforms, and Animations
Updated: May 10, 2026
5 min read
# CSS Transitions & Animations
1. Introduction
Static websites are boring. Adding subtle movements, hover effects, and loading spinners makes a website feel modern and interactive. CSS provides powerful, hardware-accelerated tools to animate your elements without using JavaScript.2. Learning Objectives
-
Smoothly transition states using
transition.
-
Move, scale, and rotate elements using
transform.
-
Create infinite loading spinners using
@keyframesandanimation.
3. Detailed Explanations
CSS Transitions
A transition smoothly changes a CSS property over a specified duration. It's usually paired with a:hover pseudo-class.
css
CSS Transforms
Transforms manipulate the physical appearance of an element without altering the document flow (other elements don't get pushed around).- Translate: Move an element X or Y pixels.
- Scale: Make it bigger or smaller.
- Rotate: Spin it.
css
CSS Keyframe Animations
While transitions only happen on state changes (like hover), animations can run infinitely on page load. You define "keyframes" (percentages of the animation).
css
4. Mini Project: Interactive Product Card
html
css
5. MCQs
Q1: Which property defines how long a hover effect takes to complete? A) transform B) transition-duration C) animation-delay D) time *Answer: B*6. Summary
Usetransition for simple hover states like button colors and subtle card lifts. Use @keyframes for complex, multi-step, or infinite animations like loading spinners. Always prioritize performance by animating transform and opacity rather than width or margin.