Learn CSS Animations
Learn CSS Animations
CSS is essential for styling web pages, and animations can bring life to your designs! Here's
how you can get started:
A great way to practice is by using platforms like MDN Web Docs and CSS Tricks.
.button {
background-color: blue;
transition: background-color 0.5s ease-in-out;
}
.button:hover {
background-color: red;
}
@keyframes bounce {
0% { transform: translateY(0); }
50% { transform: translateY(-20px); }
100% { transform: translateY(0); }
}
.ball {
1/5
animation: bounce 1s infinite;
}
Do you want to build a specific animation? I can help you code it! 🎨✨
make advanced
Alright! Let's go deeper into advanced CSS animations. Here are some cool animation
techniques:
css
@keyframes fadeInUp {
0% {
opacity: 0;
transform: translateY(20px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
.box {
opacity: 0;
animation: fadeInUp 1s ease-out forwards;
}
2/5
2. Smooth Infinite Looping Animations
Continuous and fluid animations with cubic-bezier timing functions.
css
@keyframes pulse {
0% { transform: scale(1); opacity: 1; }
50% { transform: scale(1.1); opacity: 0.7; }
100% { transform: scale(1); opacity: 1; }
}
.pulsing-button {
animation: pulse 1.5s cubic-bezier(0.25, 0.1, 0.25, 1) infinite;
}
css
.parallax {
background-image: url('your-image.jpg');
background-attachment: fixed;
background-position: center;
background-size: cover;
height: 100vh;
}
3/5
A cool hover effect using perspective and backface visibility.
css
.flip-card {
width: 200px;
height: 300px;
perspective: 1000px;
}
.flip-card-inner {
width: 100%;
height: 100%;
position: relative;
transform-style: preserve-3d;
transition: transform 0.6s;
}
.flip-card:hover .flip-card-inner {
transform: rotateY(180deg);
}
.flip-card-front,
.flip-card-back {
width: 100%;
height: 100%;
position: absolute;
backface-visibility: hidden;
}
.flip-card-back {
transform: rotateY(180deg);
background-color: #f00;
}
4/5
If you want smooth, JavaScript-controlled animations, GSAP (GreenSock Animation
Platform) is the best.
html
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js">
</script>
<script>
gsap.to(".box", { duration: 2, x: 300, rotation: 360, ease: "elastic" });
</script>
5/5