DEV Community

Cover image for Rainbow 🌈 animation page background
Matt Ellen
Matt Ellen

Posted on • Updated on

Rainbow 🌈 animation page background

I was inspired by

to show off an old animation of mine. It's probably possible to do this with just CSS, so if you know how post it in the comments!

I had an idea to make balls zoom across the screen, in the colours of the rainbow. Here's the result (it can take a second to load, so be patient):

I wrote this before I knew about let and const, so please forgive that! In fact there are a few things I would change now, like using template strings. But, I suppose, if it isn't broken I shouldn't try to fix it :D

The frames are generated upfront, so the animation is just changing pictures, not calculating each frame. You can see the data-url updating in the page's background for each frame.

The speed of each ball is random.

If you save the background image, it will tile perfectly.

Discussion (0)