Not long ago, animation on the web was a bit rudimentary – save for add-on technology such as Flash. The movements were basic and often trended towards cartoonish. That’s not necessarily a bad thing, just not a great fit for every project.
To prove it, we’ve found some beautiful code snippets that bring an element of realism to web animation. They range from full-on recreations to examples that use a just hint of real-world effects. Enjoy!
You might also like our collection of Snippets for Creating Neumorphic UIs
The toggle switch has become a staple of web design – but this snippet takes things to another level. By adding a realistic surface and jittery backlight, this pure CSS animation looks like it belongs on a piece of machinery. Clicking the switch also produces a satisfying on/off effect.
Something to Sea
Here’s a unique example of parallax scrolling. The large bird’s eye view photo of a city is eye-catching in its own right. But move your cursor, and the perspective shifts as if you’re standing atop a building, looking down on the world below. It’s subtle but oh-so-cool.
Exploring Mother Earth
Taking things even further out into the stratosphere, this snippet offers an interactive look at Earth, powered by Three.js. Left to itself, the planet slowly spins while a field of stars moves in the background. But there’s more! Click and drag the screen to change the planet’s position to suit your liking. Hint: there’s a moon hidden in there somewhere.
Nintendo Switch Demo
This gaming device animation takes a different, and perhaps more classic, approach. A neumorphic Nintendo Switch acts as a container for a video from the popular game Animal Crossing: New Horizons. Put it all together, and it looks like the game is being played right in front of you.
The beauty of this snippet is in its subtlety. The hero area utilizes an attention-grabbing photo background of a volcano. Slow-moving wisps of smoke (powered by CSS) provide the perfect accent piece. It goes to show that the little details can make a world of difference.
Rays of Light
Driving through the mountains can be inspiring. This animation will bring some of that experience to your screen. It’s the lighting effects that really impress. As the sun rises and sets, check out the intensity, shadows, and movement. You can almost feel the heat!
Just Watch This
Those of us who grew up in the 1980s and 1990s will remember these digital watches. It seemed like every kid had one. Not only does this snippet recreate the look of a classic Casio, but it’s also interactive. Click the “Light” button on the upper left to get a nighttime view of the screen. Ah, the memories.
Imagining a New Level of Reality
The examples above serve as a fun reminder of what’s possible when combining great tools with creativity. As languages, frameworks, and hardware evolve, realistic animation effects become more attainable.
Just think: in the early 2000s, a similar degree of realism would have taken some pretty robust software for both developers and users. Now, it can be built and viewed without a massive investment or buggy browser plugins.