Skip to: Content or Footer

Pure CSS animation with graphics and mix blend mode

Introduction

This was my first attempt at a timeline animation. A friend of mine (Chris Cleary) asked me to look into adding an animation on his landing page. We decided in the end not to publish it but I learnt a good deal in the process.

You have set a preference for reduced motion in your System Settings so no animation will be shown.

Using mix-blend-mode to get around an issue

One of the trickiest parts of what I was trying to achieve was the green section that intersects the blue and yellow ‘C’s. I’d created a shape in Photoshop and was in the process of absolutely positioning it when it struck me that there had to be a way to blend the colours. Enter mix-blend-mode and using the images colours themselves to create the green part.

mix-blend-mode: multiply;

By adding the multiply to both green and yellow images the bleed through blend is the desired green (or at least an approximation that was close enough.)

Smooth easing-function timing with cubic-bezier

A large part of what I like about the routine is the timing to add fluid natural motion. This was achieved with the Cubic Bézier easing function which smoothes down the start and end of the interpolation. Check out the demo files which you can download and play with to add and try out your own values.

Accessibility, prefers Reduced Motion

What if the user has set a preference for Reduced Motion? In this case the animation and Refresh Animation button are removed. There is also some warning text indicating that the animation will not work. Give it a try, set prefers-reduced-motion in your System Settings (Accessibility > Display > Reduce Motion) and see what happens here…

Download sample code

I’ve assembled all the parts so that you can play with them. The standard – software is provided “as is”, without warranty of any kind – applies here.

Download File
Zip Files Info
index.html
1.7KB
style.css
7.4KB
readme.txt
460 bytes
cc-logo-static.png
4.2KB
yellow-c.png
2.7KB
green-c.png
2.7KB
green-half-c.png
1.7KB
blue-c.png
2.7KB
File: barrd-cc-animation.zip
Details: 8 files @ 23KB

That’s all folks

Whilst the original code was never released into the wild I’ve added this to hopefully inspire others to give timeline animations a try.

The coding was never finished and requires optimisation including swapping PNGs for SVGs. If you create something you’re happy with please let me know so I can take a look (and continue learning.)

// End of Project

More Information

Dave Barr

Bristol based Scottish Expat who has 20+ years experience of Web Development and is continually on the look out to improve his skill sets. Learning new and innovative solutions for current requirements in the world of IT, WebDev and eCommerce.

About Dave Barr

Image for Dave Barr
Bristol based Scottish Expat who has 20+ years experience of Web Development and is continually on the look out to improve his skill sets. Learning new and innovative solutions for current requirements in the world of IT, WebDev and eCommerce.

Read more about Dave

Back to Top

Click to Copy