TECHTRICKS365

Smashing Animations Part 1: How Classic Cartoons Inspire Modern CSS — Smashing Magazine TechTricks365

Smashing Animations Part 1: How Classic Cartoons Inspire Modern CSS — Smashing Magazine TechTricks365


Have you ever thought about how the limitations of early cartoon animations might relate to web design today? From looping backgrounds to minimal frame changes, these retro animation techniques have surprising parallels to modern CSS. In this article, pioneering author and web designer Andy Clarke shows how he applied these principles to Emmy-winning composer Mike Worth’s new website, using CSS to craft engaging and fun animations that bring his world to life.

Browser makers didn’t take long to add the movement capabilities to CSS. The simple :hover pseudo-class came first, and a bit later, the transitions between two states. Then came the ability to change states across a set of @keyframes and, most recently, scroll-driven animations that link keyframes to the scroll position.

Even with these added capabilities, CSS animations have remained relatively rudimentary. They remind me of the Hanna-Barbera animated series I grew up watching on TV.

These animated shorts lacked the budgets given to live-action or animated movies. They were also far lower than those available when William Hanna and Joseph Barbera made Tom and Jerry shorts while working for MGM Cartoons. This meant the animators needed to develop techniques to work around their cost restrictions and the technical limitations of the time.

They used fewer frames per second and far fewer cells. Instead of using a different image for each frame, they repeated each one several times. They reused cells as frequently as possible by zooming and overlaying additional elements to construct a new scene. They kept bodies mainly static and overlayed eyes, mouths, and legs to create the illusion of talking and walking. Instead of reducing the quality of these cartoons, these constraints created a charm often lacking in more recent, bigger-budget, and technically advanced productions.

(Large preview)

The simple and efficient techniques developed by Hanna-Barbera’s animators can be implemented using CSS. Modern layout tools allow web developers to layer elements. Scaleable Vector Graphics (SVG) can contain several frames, and developers needn’t resort to JavaScript; they can use CSS to change an element’s opacity, position, and visibility. But what are some reasons for doing this?

Animations bring static experiences to life. They can improve usability by guiding people’s actions and delighting or surprising them when interacting with a design. When carefully considered, animations can reinforce branding and help tell stories about a brand.

Design by Andy Clarke, Stuff & Nonsense. Mike Worth’s website will launch in June 2025, but you can see examples from this article on CodePen. (Large preview)

Introducing Mike Worth

I’ve recently been working on a new website for Emmy-award-winning game composer Mike Worth. He hired me to create a bold, retro-style design that showcases his work. I used CSS animations throughout to delight and surprise his audience as they move through his website.

Mike loves ’80s and ’90s animation — especially Disney’s Duck Tales. Unsurprisingly, my taste in cartoons stretches back a little further to the 1960s Hanna-Barbera shows like Dastardly and Muttley in Their Flying Machines, Scooby-Doo, The Perils of Penelope Pitstop, Wacky Races, and, of course, Yogi Bear.

So, to explain how this era of animation relates to CSS, I’ve chosen an episode of The Yogi Bear Show, “Home Sweet Jellystone,” first broadcast in 1961. In this story, Ranger Smith inherits a mansion and (spoiler alert) leaves Jellystone.

The Yogi Bear Show, copyright Warner Bros. Entertainment Inc. (Large preview)

Dissecting Movement

In this episode, Hanna-Barbera’s techniques become apparent as soon as a postman arrives with a telegram for Ranger Smith. The camera pans sideways across a landscape painting by background artist Robert Gentle to create the illusion that the postman is moving.

The Yogi Bear Show, copyright Warner Bros. Entertainment Inc. (Author’s recreation) (Large preview)

The background loops when a scene lasts longer than a single pan of Robert Gentle’s landscape painting, with bushes and trees appearing repeatedly.

The Yogi Bear Show, copyright Warner Bros. Entertainment Inc. (Large preview)

This can be recreated using a single element and an animation that changes the position of its background image:

@keyframes background-scroll {
  0% { background-position: 2750px 0; }
  100% { background-position: 0 0; }
}

div {
  overflow: hidden;
  width: 100vw;
  height: 540px;
  background-image: url("…");
  background-size: 2750px 540px;
  background-repeat: repeat-x;
  animation: background-scroll 5s linear infinite;
}

See the Pen [Yogi Bear background image scroll [forked]](https://codepen.io/smashingmag/pen/NPPzgyq) by Andy Clarke.

See the Pen Yogi Bear background image scroll [forked] by Andy Clarke.

Although beautifully executed, Robert Gentle’s background paintings were often remarkably simple. The mansion’s interior background rushes past to create the illusion of Ranger Smith dashing across it, so it needed very few details.

The Yogi Bear Show, copyright Warner Bros. Entertainment Inc. (Large preview)

The economy of movement was essential for producing these animated shorts cheaply and efficiently. The postman’s motorcycle bounces, and only his head position and facial expressions change, which adds a subtle hint of realism.

The Yogi Bear Show, copyright Warner Bros. Entertainment Inc. Sequence shortened. (Large preview)

Likewise, only Ranger Smith’s facial expression and leg positions change throughout his walk cycle as he dashes through his mansion. The rest of his body stays static.

The Yogi Bear Show, copyright Warner Bros. Entertainment Inc. Sequence shortened. (Large preview)

In a discarded scene from my design for his website, the orangutan adventurer mascot I created for Mike Worth can be seen driving across the landscape.

Mike Worth’s website will launch in June 2025, but you can see examples from this article on CodePen. (Large preview)

I drew directly from Hanna-Barbera’s bouncing and scrolling technique for this scene by using two keyframe animations: background-scroll and bumpy-ride. The infinitely scrolling background works just like before:

@keyframes background-scroll {
  0% { background-position: 960px 0; }
  100% { background-position: 0 0; }
}

I created the appearance of his bumpy ride by animating changes to the keyframes’ translate values:

@keyframes bumpy-ride {
  0% { translate: 0 0; }
  10% { translate: 0 -5px; }
  20% { translate: 0 3px; }
  30% { translate: 0 -3px; }
  40% { translate: 0 5px; }
  50% { translate: 0 -10px; }
  60% { translate: 0 4px; }
  70% { translate: 0 -2px; }
  80% { translate: 0 7px; }
  90% { translate: 0 -4px; }
  100% { translate: 0 0; }
}

figure {
  /* ... */
  animation: background-scroll 5s linear infinite;
}

img {
  /* ... */
  animation: bumpy-ride 1.5s infinite ease-in-out;
}

See the Pen [Mike Worth background image scroll [forked]](https://codepen.io/smashingmag/pen/ByyVZrB) by Andy Clarke.

See the Pen Mike Worth background image scroll [forked] by Andy Clarke.

As Michelle Barker wrote about here at Smashing Magazine back in 2021:

“When working with motion on the web, it’s important to consider that not everyone experiences it the same way. What might feel smooth and slick to some might be annoying or distracting to others — or worse, induce feelings of sickness or even cause seizures.”

— Michelle Barker

You can prevent that from happening by turning off animations when someone has chosen reduced motion in their browser by using the prefers-reduced-motion media query:

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
}

Reusing Elements

Since each episode’s budget and production time were limited, William Hanna and Joseph Barbera created a streamlined process for producing their animations. They used as few as 2,000 individual drawings and just a few background paintings per episode, often reusing them on several episodes.

The Yogi Bear Show, copyright Warner Bros. Entertainment Inc. (Large preview)

Watch the episode and you’ll see these trees appear over and over again throughout “Home Sweet Jellystone.” Behind Yogi and Boo-Boo on the track, in the bushes, and scaled up in this close-up of Boo-Boo:

The Yogi Bear Show, copyright Warner Bros. Entertainment Inc. (Large preview)

The animators also frequently layered foreground elements onto these background paintings to create a variety of new scenes:

On the left: The Yogi Bear Show, copyright Warner Bros. Entertainment Inc. On the right: Author’s edit.(Large preview)

In my deleted scene from Mike Worth’s website, I introduced these rocks into the foreground to add depth to the animation:

Mike Worth’s website will launch in June 2025, but you can see examples from this article on CodePen. (Large preview)

If I were using bitmap images, this would require just one additional image:

figure {
  position: relative; 

  #bumpy-ride { ... }

  #apes-rock {
    position: absolute;
    width: 960px;
    left: calc(50% - 480px);
    bottom: 0;
  }
}

See the Pen [Mike Worth layered animation [forked]](https://codepen.io/smashingmag/pen/xbbzraj) by Andy Clarke.

See the Pen Mike Worth layered animation [forked] by Andy Clarke.

Had I continued developing this scene, I might’ve added a slower scrolling animation to those rocks to introduce a parallax effect for even greater realism.

Looping Frames Create Movement

To meet their limited budget and production schedules, Hanna Barbera’s animators carefully planned their animations and cleverly only animated specific elements. While heads and facial expressions make characters talk and their legs change to make them walk, most characters’ bodies remain relatively static. So, throughout this entire scene of Ranger Smith walking and talking his way across his cabin, only his face and legs are animated:

The Yogi Bear Show, copyright Warner Bros. Entertainment Inc. (Large preview)

Likewise, when the ranger reads his telegram, only his eyes and mouth move:

The Yogi Bear Show, copyright Warner Bros. Entertainment Inc. (Large preview)

If you’ve wondered why both Ranger Smith and Yogi Bear wear collars and neckties, it’s so the line between their animated heads and faces and static bodies is obscured:

The Yogi Bear Show, copyright Warner Bros. Entertainment Inc. Author’s recreation. (Large preview)

SVG delivers incredible performance and also offers fantastic flexibility when animating elements. The ability to embed one SVG inside another and to manipulate groups and other elements using CSS makes it ideal for animations.

I replicated how Hanna-Barbera made Ranger Smith and other characters’ mouths move by first including a group that contains the ranger’s body and head, which remain static throughout. Then, I added six more groups, each containing one frame of his mouth moving:


  
  ...

  
  ...
  ...
  ...
  ...
  ...
  ...

I used CSS custom properties to define the speed at which characters’ mouths move and how many frames are in the animation:

:root {
  --animation-duration: 1s;
  --frame-count: 6;
}

Then, I applied a keyframe animation to show and hide each frame:

@keyframes ranger-talking {
  0% { visibility: visible; }
  16.67% { visibility: hidden; }
  100% { visibility: hidden; }
}

[class*="frame"] {
  visibility: hidden;
  animation: ranger-talking var(--animation-duration) infinite;
}

Before finally setting a delay, which makes each frame visible at the correct time:

.frame-1 {
  animation-delay: calc(var(--animation-duration) * 0 / var(--frame-count));
}

/* ... */

.frame-6 {
  animation-delay: calc(var(--animation-duration) * 5 / var(--frame-count));
}

See the Pen [Ranger Smith talking [forked]](https://codepen.io/smashingmag/pen/QwwxgJE) by Andy Clarke.

See the Pen Ranger Smith talking [forked] by Andy Clarke.

Working With Mike Worth

When Mike Worth and I sat down to discuss working together, we both understood that there would be neither the budget nor the time to create a short animated cartoon for his website. We also knew that video would be the correct format for a fully animated production, but we were keen to explore how CSS could bring what would’ve otherwise been static images to life. So, this begs the question of why and when to use CSS animations.

Ambient Animations

Subtle ambient animations contribute to a website’s atmosphere and help with storytelling without distracting from its content or functionality.

For Mike Worth’s about-page illustration, I shone shafts of light onto a stone tablet to add depth to an otherwise flat image. Inside my SVG, I added a path for the light and reduced its opacity to .25:

I then defined an SVG filter to blur the edges of my light shafts and linked it to my path:

Finally, I added a subtle ambient animation that rotates the light shafts and creates a more natural feel:

@keyframes shaft-rotate {
  0% { rotate: 2deg; }
  50% { rotate: -2deg; }
  100% { rotate: 2deg; }
}

.light-shaft {
  animation: shaft-rotate 20s infinite;
  transform-origin: 100% 0;
}

See the Pen [Mike Worth’s about page animation [forked]](https://codepen.io/smashingmag/pen/bNNKROE) by Andy Clarke.

See the Pen Mike Worth’s about page animation [forked] by Andy Clarke.

Can you throw more light on Mike’s navigation?

See the Pen [Light up Mike Worth about page [forked]](https://codepen.io/smashingmag/pen/ZYYRyVJ) by Andy Clarke.

See the Pen Light up Mike Worth about page [forked] by Andy Clarke.

Animations On Interactions

In the same way that a :hover pseudo-class provides valuable visual feedback when someone interacts with an element, CSS animations can create a deeper connection between people and a design.

I included an Easter egg interaction on Mike Worth’s review page illustration. The big red button turns the desk lamp on and off, much to the consternation of Mike’s orangutan mascot, who’s trying to study his map. To implement this, I applied a data- attribute to the SVG illustration:


  

And added a red button for any curious visitor to press:

When someone presses that red button, the light goes out, which is made possible by changing the value of the SVG’s data- attribute from lights-on to lights-off.

Several elements within the illustration light up when the desk lamp is on. To make this happen, I applied a class value to those specific items:


And used the data-attribute value to toggle the glow on and off when someone presses the lamp’s button:

[data-lights="lights-on"] .lamp-glow {
  opacity: 1;
  transition: opacity .25s linear;
}

[data-lights="lights-off"] .lamp-glow {
  opacity: .25;
  transition: opacity .25s linear;
}

When someone turns the lamp on, it flickers at what appears to be random intervals. I first applied a class value to the flickering elements:


Then, I hid them when the lamp was turned off:

[data-lights="lights-off"] .lamp-flicker {
  visibility: hidden;
}

Finally, I created a keyframe animation that flickers the lamp light’s opacity at seemingly random intervals:

@keyframes lamp-flicker {
  0%, 19.9%, 22%, 62.9%, 64%, 64.9%, 70%, 100% { opacity: 1; }
  20%, 21.9%, 63%, 63.9%, 65%, 69.9% { opacity: .5; }
}

[data-lights="lights-on"] .lamp-flicker {
  animation: lamp-flicker 3s 3s linear infinite;
}

Animations can also tempt people to venture deeper into a design, so I made the crystal skull on the desk vibrate to hint at something more to discover:


  

@keyframes crystal-skull-vibrate {
  0% { translate: 0 0; }
  20% { translate: -2px 2px; }
  40% { translate: -2px -2px; }
  60% { translate: 2px 2px; }
  80% { translate: 2px -2px; }
  100% { translate: 0 0; }
}

#crystal-skull:hover {
  animation: crystal-skull-vibrate .5s ease 0s infinite normal forwards;
}

See the Pen [Mike Worth’s review page animation [forked]](https://codepen.io/smashingmag/pen/YPPvQBg) by Andy Clarke.

See the Pen Mike Worth’s review page animation [forked] by Andy Clarke.

Animations Tell Stories

When carefully considered, animations can reflect a brand’s identity and help tell its story.

Mike Worth’s brand is high-energy — just like his personality — and the story he tells about his work as a video game composer is engaging and playful. Mike wanted every interaction with his website to bring his personality to the screen.

Should someone get lost along their journey, they’ll end up on Mike’s 404 page, where his hero has a sinking feeling. While Mike’s orangutan adventurer slips deeper and deeper into the quicksand, animated bubbles rise:


@keyframes four-oh-dear-bubbles {
  0% { 
    animation-timing-function: ease-in; 
    opacity: 1; 
    transform: translateY(45px);
  }
  24% { 
    opacity: 1; 
  }
  40% { 
    animation-timing-function: ease-in; 
    translate: 0 24px;
  }
  65% { 
    animation-timing-function: ease-in;
    translate: 0 12px;
  }
  82% { 
    animation-timing-function: ease-in;
    translate: 0 6px;
  }
  93% { 
    animation-timing-function: ease-in;
    translate: 0 4px;
  }
  25%, 55%, 75%, 87% { 
    animation-timing-function: ease-out;
    translate: 0 0;
  }
  100% { 
    animation-timing-function: ease-out;
    opacity: 1; 
    translate: 0 0;
  }
}

.four-oh-dear-bubble {
  animation: four-oh-dear-bubbles 2s ease 0s infinite alternate forwards; }

See the Pen [Mike Worth’s 404 page animation [forked]](https://codepen.io/smashingmag/pen/ZYYRyPX) by Andy Clarke.

See the Pen Mike Worth’s 404 page animation [forked] by Andy Clarke.

Bringing It All To Life

Just as the animators at Hanna-Barbera turned technical limitations into their signature style, CSS animations enable web professionals to craft characterful experiences. By layering elements, looping frames, and applying subtle movement, you can inject personality into a design while improving someone’s experience.

The Yogi Bear Show, copyright Warner Bros. Entertainment Inc. (Large preview)

In my design for Mike Worth’s website, animation isn’t just for decoration; it tells a compelling story about him and his work. Every movement reflects his brand identity and makes his website an extension of his creative world.

Think beyond movement the next time you reach for a CSS animation. Consider emotions, identity, and mood, too. After all, a well-considered animation can do more than catch someone’s eye. It can capture their imagination.

(Large preview)

Mike Worth’s website will launch in June 2025, but you can see examples from this article on CodePen now.


(gg, yk)




Exit mobile version