Top 5 CSS Animation Tricks
- Sanjana Dhasmana

- Aug 20
- 4 min read

In the first part of this blog series (Top 5 CSS Layout Tricks That Will Change How You Code), we uncovered CSS layout tricks - which reshapes the way modern interfaces are built; from container queries to logical properties.
In this post, we’ll cover the CSS Animation tricks that will bring movement and style to your web designs - all without using JavaScript.
So, if you are ready to transform static designs into interactive, engaging experiences that enhance usability and captivate your audience, let’s get started.
1. Scroll Driven animation
A scroll-driven animation is linked to the scroll position of a scroll container. This means that as you scroll up or down, the linked animation scrubs forward or backward in direct response.
Examples of this are effects such as parallax background images or reading indicators which move as you scroll.

Code snippet:
img {
width: 200px;
height: auto;
animation: grow-shrink 1s linear both;
animation-timeline: scroll(); /* link animation to page scroll */
animation-range: 0% 100%; /* play from top to bottom */
}
@keyframes grow-shrink {
from {
transform: scale(0.5); /* smaller at top */
}
to {
transform: scale(2); /* larger at bottom */
}
} Scroll-linked animations transform scrolling into an interactive design tool. Instead of relying on heavy JavaScript, animations run natively in CSS, delivering smoother performance, reduced CPU usage, and cleaner code. This creates faster, more immersive experiences, empowering designers to craft engaging narratives and fluid user journeys with ease.
2. View Transition API Animation
The View Transitions API lets you create smooth, animated transitions between different DOM states — like going from one page to another or changing content on a single page — with almost no JavaScript.
Think of it like native page animations, where the browser automatically morphs old elements into new ones instead of abruptly replacing them.

Code snippet:
@media (prefers-reduced-motion: reduce) {
.post-title { view-transition-name: post-title; }
.post-link { view-transition-name: post-title; }
} The View Transitions API replaces clunky, abrupt DOM updates with fluid, cinematic animations that improve user experience. It reduces the need for heavy animation libraries, runs natively for better performance, and gives designers fine-grained control over how elements morph between states.
3. Glassmorphism & Backdrop Effects
Glassmorphism is a modern UI design trend where elements look like frosted or translucent glass. It creates a sense of depth by layering semi-transparent surfaces over colorful or blurred backgrounds.

In CSS, this is usually achieved with backdrop-filter and transparency in backgrounds.
.card {
background: rgba(255, 255, 255, 0.2); /* semi-transparent */
border-radius: 20px;
backdrop-filter: blur(10px) saturate(150%);
border: 1px solid rgba(255, 255, 255, 0.3);
padding: 2rem;
color: white;
} Glassmorphism and backdrop effects improve user interfaces by adding depth and elegance without overwhelming content. They allow designers to highlight important elements while keeping context visible, creating a futuristic and premium look. Because these effects are now hardware-accelerated in browsers, they run smoothly and enhance UX without sacrificing performance.
4. Bounce-In Effect for Call-to-Action
A lively bounce animation that makes an element pop into view, perfect for highlighting a special offer or form.

Code snippet:
.cta {
animation: bounceIn 1s ease;
}
@keyframes bounceIn {
0% { transform: scale(0.5); opacity: 0; }
60% { transform: scale(1.2); opacity: 1; }
100% { transform: scale(1); }
} A bounce draws the eye immediately. This is especially useful for time-sensitive content or offers, as it naturally directs attention without being overly aggressive.
5. CSS Motion Path
Path-based motion lets you animate an element along a custom path (straight line, curve, or even a complex SVG shape) directly in CSS. Before this, developers had to rely on JavaScript + SVG animations or external libraries like GSAP.

Code snippet:
#motion-demo {
offset-path: path("M20,20 C20,100 200,0 200,100");
animation: move 3000ms infinite alternate ease-in-out;
width: 40px;
height: 40px;
background: cyan;
}
@keyframes move {
0% {
offset-distance: 0%;
}
100% {
offset-distance: 100%;
}
} Path-based motion makes complex motion graphics possible with just CSS, eliminating the need for heavy JavaScript libraries. This leads to smoother, GPU-accelerated animations, less code, and more creative freedom. Designers can craft engaging, dynamic user experiences with precise control over motion while keeping pages lightweight and performant.
Pro Tips for Better CSS Animations
Animate Transform & Opacity First- Always favor transform (translate, scale, rotate) and opacity for smooth effects. Avoid animating layout properties like width, height, or top, which trigger expensive reflows.
Use will-change Wisely- Apply will-change: transform; or will-change: opacity; to elements that are frequently animated. This serves as a hint to the browser, allowing it to optimize rendering through GPU acceleration. However, excessive use can lead to unnecessary memory consumption and degrade performance.
Keep It Short & Subtle- Animations between 200ms and 500ms typically feel natural to the users. Faster feels abrupt while slower feels unresponsive. To enhance realism and create smoother transitions, apply appropriate easing functions such as ease, ease-in-out, or custom cubic-bezier curves.
Respect prefers-reduced-motion- Always provide fallbacks for users who disable animations. Use the following to ensure accessibility while keeping your site inclusive:
@media (prefers-reduced-motion: reduce) {
{ animation: none !important; transition: none !important; }
} Combine Animations with Purpose- “Animate with intention — every movement should respond to user actions like hover, scroll, or navigation, or support the story your design is telling. When motion has purpose, it not only enhances clarity but also directs attention where it matters most.”
Test Across Devices- A fluid animation on desktop might lag on low-end mobiles. Test on multiple browsers and devices to make sure the experience is consistent.
Wrapping Up
Animations are more than decoration — they’re a way to guide users, reinforce interactions, and make your product feel polished. By mastering fade-ins, hover effects, animated backgrounds, slide-ins, and pure CSS loaders, you can breathe life into your UI without adding extra dependencies.
References
Animate elements on scroll with Scroll-driven animations | CSS and UI | Chrome for Developers
Toe Dipping Into View Transitions | CSS-Tricks
offset-position


Comments