CSS animations allow you to create dynamic visual effects on web pages. Here's a quick guide to get started:
📌 Basics of CSS Animations
@keyframes
defines the animation sequence@keyframes example { 0% { transform: scale(1); } 100% { transform: scale(1.5); } }
animation
property applies the animation to elements.box { animation: example 2s infinite; }
🔄 Key Concepts
- Duration (
animation-duration
) - Timing Function (
animation-timing-function
) - Delay (
animation-delay
) - Iteration Count (
animation-iteration-count
) - Direction (
animation-direction
)
📈 Example: Bouncing Box
<div class="box"></div>
.box {
width: 100px;
height: 100px;
background: #3498db;
margin: 50px auto;
animation: bounce 1.5s ease-in-out infinite;
}
@keyframes bounce {
0% { transform: translateY(0); }
50% { transform: translateY(-20px); }
100% { transform: translateY(0); }
}
🚀 Advanced Techniques
- Use
transform
for complex movements - Combine with
opacity
for fade effects - Apply
animation-fill-mode
for state control
📚 Expand Your Knowledge
💡 Remember to use @keyframes
for defining animations and the animation
shorthand property to apply them. Experiment with different timing functions and durations to create unique effects!