TGViewer
Web Development Web Development @webdevcoursefree · 79.7K subscribers
Post #3473 5.02K
Now, let's move to the the next topic:

CSS Animations & Transitions Breakdown ✅

✨ Why animations matter
- Guide user attention
- Improve user experience
- Make UI feel alive
- Give feedback to actions
Good animation is subtle, not flashy.

🔁 Transitions vs Animations

🔹 Transition
- Used for simple state changes
- Triggered by hover, focus, click
- One start → one end

🔹 Animation
- Runs automatically
- Can repeat
- Multiple steps

Rule of thumb
👉 Use transitions for interactions
👉 Use animations for continuous effects

🎯 CSS Transitions Explained
Transition smoothly changes a property.

Basic properties
- transition-property
- transition-duration
- transition-timing-function
- transition-delay
Most common shorthand transition: all 0.3s ease;

🖱️ Transition Example. Button hover
button {
background-color: #007bff;
color: white;
padding: 12px 20px;
border: none;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #0056b3;
}

What happens
- Color changes smoothly
- No sudden jump

🎞️ CSS Animations Explained
Animations use keyframes.
Keyframes define steps.
Basic syntax
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}

Apply animation
.box {
animation: fadeIn 1s ease-in-out;
}

🎛️ Animation properties you must know
- animation-name
- animation-duration
- animation-timing-function
- animation-delay
- animation-iteration-count
Example animation: bounce 1s infinite;

📌 Real-world animation examples
- Loading spinner
- Fade-in cards
- Button pulse
- Skeleton loaders

⚠️ Common beginner mistakes
- Overusing animations
- Long durations
- Animating layout-breaking properties
- Ignoring performance

Avoid animating
- width
- height
- margin

Prefer animating
- opacity
- transform

✅ Best practices
- Keep duration between 0.2s–0.5s
- Use ease or ease-in-out
- Animate only when needed
- Test on low-end devices

🧪 Mini practice task
- Add hover transition to a button
- Animate card fade-in on load
- Create a simple loading spinner

✅ Mini Practice – Solutions

🎨 CSS Transitions & Animations

🟦 1️⃣ Add hover transition to a button

HTML
<button class="btn">Click Me</button>

CSS
.btn {
background-color: #007bff;
color: white;
padding: 12px 24px;
border: none;
border-radius: 6px;
cursor: pointer;
transition: background-color 0.3s ease, transform 0.2s ease;
}
.btn:hover {
background-color: #0056b3;
transform: scale(1.05);
}

✅ Result
- Smooth color change
- Slight zoom on hover
- Feels responsive

🗂️ 2️⃣ Animate card fade-in on page load

HTML
<div class="card">Card Content</div>

CSS
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.card {
padding: 30px;
background-color: #f2f2f2;
border-radius: 8px;
animation: fadeIn 0.6s ease-in-out;
}

✅ Result
- Card fades in smoothly
- Slight upward motion
- Professional UI feel

🔄 3️⃣ Create a simple loading spinner

HTML
<div class="spinner"></div>

CSS
.spinner {
width: 40px;
height: 40px;
border: 4px solid #ddd;
border-top: 4px solid #007bff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}

✅ Result
- Continuous spinning loader
- Used during API calls
- Common in real apps

🧠 Key takeaway
- Transitions handle interactions
- Animations handle motion
- transform and opacity are performance-friendly
- Less animation = better UX

Double Tap ♥️ For More
  • ❤ 17
  • 👍 3
More from @webdevcoursefree
  1. Oct 16, 2026🌐 Web Development Roadmap — Part 18 HTML Lists Lists are used whenever information needs…
  2. Oct 14, 2026🌐 Web Development Roadmap — Part 17 HTML Images — <img> Tag Images make webpages more vis…
  3. Oct 13, 2026𝗧𝗢𝗣 𝗙𝗥𝗘𝗘 𝗖𝗢𝗨𝗥𝗦𝗘𝗦 𝗧𝗢 𝗕𝗢𝗢𝗦𝗧 𝗬𝗢𝗨𝗥 𝗦𝗞𝗜𝗟𝗟𝗦 𝗜𝗡 𝟮𝟬𝟮𝟲! Explor…
  4. Oct 12, 2026For example: Go to Profile → <a> Submit Form → <button> Open Article → <a> Delete Account…
  5. Oct 12, 2026🌐 Web Development Roadmap — Part 16 HTML Links — Tag Links are one of the most important…
  6. Oct 12, 2026🚀 𝗪𝗵𝗶𝗰𝗵 𝗧𝗲𝗰𝗵 𝗦𝗸𝗶𝗹𝗹 𝗪𝗶𝗹𝗹 𝗬𝗼𝘂 𝗠𝗮𝘀𝘁𝗲𝗿 𝗶𝗻 𝟮𝟬𝟮𝟲? Want to buil…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →