Bring your websites to life with smooth animations!
Transitions smoothly change CSS properties over time. Perfect for hover effects and simple animations!
.button {
background: blue;
transition: background 0.3s ease;
}
.button:hover {
background: red; /* Smoothly changes from blue to red */
}
transition: property duration timing-function delay;
/* Examples: */
transition: all 0.3s ease;
transition: background 1s linear 0.5s;
transition: transform 0.5s ease-in-out;
Timing Functions:
• ease - Slow start, fast middle, slow end (default)
• linear - Same speed throughout
• ease-in - Slow start
• ease-out - Slow end
• ease-in-out - Slow start and end
Animations using @keyframes allow complex, multi-step animations that loop!
/* Define the animation */
@keyframes slide {
from { left: 0; }
to { left: 300px; }
}
/* Use the animation */
.box {
animation: slide 2s ease infinite;
}
Transform changes an element's shape, size, position, or rotation:
transform: translate(50px, 100px); /* Move */
transform: rotate(45deg); /* Rotate */
transform: scale(1.5); /* Make bigger */
transform: skew(10deg); /* Slant */
/* Combine multiple transforms */
transform: translate(50px, 0) rotate(45deg) scale(1.2);
Challenge: Create Your Animations!
📚 Class 8 - Advanced CSS • Animate Everything! 🚀