DEV Community

Deepak Jaiswal
Deepak Jaiswal

Posted on

Top 10 CSS Animation Tricks Most Developers Don’t Know

Everyone knows transition: all 0.3s ease and a basic @keyframes fade-in. But CSS has quietly grown some genuinely powerful animation features over the last few years — most of them buried in spec updates that never made it into the average tutorial. Here are ten CSS animation techniques that fly under the radar but can seriously upgrade your UI work.

  1. Animating Gradients and Custom Properties with @property Normally, you can’t animate a CSS gradient’s angle or color stops directly — the browser doesn’t know how to interpolate them. The @property rule fixes this by letting you register a custom property with a defined type (, , , etc.), which makes it animatable.
@property --angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}
.button {
  background: conic-gradient(from var(--angle), #ff6ec4, #7873f5, #ff6ec4);
  animation: spin 3s linear infinite;
}
@keyframes spin {
  to { --angle: 360deg; }
}
Enter fullscreen mode Exit fullscreen mode

This unlocks smooth animated gradients, glowing borders, and rotating conic effects — all without JavaScript.

  1. Scroll-Driven Animations with animation-timeline Instead of writing scroll-listener JavaScript, you can now tie an animation directly to scroll position using animation-timeline: scroll() or view().
.progress-bar {
  animation: grow linear;
  animation-timeline: scroll(root);
}
@keyframes grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
Enter fullscreen mode Exit fullscreen mode

The view() timeline is even more interesting — it animates an element based on its visibility inside the viewport, perfect for reveal-on-scroll effects with zero JS and zero Intersection Observer boilerplate.

  1. Motion Path Animation with offset-path You can move an element along an arbitrary path — not just in straight lines — using offset-path.
.satellite {
  offset-path: path('M 10 80 Q 95 10 180 80');
  animation: travel 4s linear infinite;
}
@keyframes travel {
  0% { offset-distance: 0%; }
  100% { offset-distance: 100%; }
}
Enter fullscreen mode Exit fullscreen mode

Combine it with offset-rotate: auto and the element will automatically orient itself along the curve, which is great for loading indicators, mascots, or decorative motion graphics.

for more such animation visit

https://medium.com/@deepakjais/top-10-css-animation-tricks-most-developers-dont-know-ec89d2485aeb

Top comments (0)