DEV Community

Dom (dcode)
Dom (dcode)

Posted on

Spice up your page loads with subtle animations!

In today's article I wanted to share a little twist that I like to include on some of my websites to enhance the overall user experience - adding subtle animations on page load.

I think this really adds to the website, and in some way, makes it feel a little snappier than it actually is.


You'll want to pick a portion of your site (usually the main content) to apply the animation to, for example:

<div class="container">
    <!-- body content here -->
Enter fullscreen mode Exit fullscreen mode


For the CSS, we need to apply an animation to the .container class, and then specify the keyframes for it. Let's identify the keyframes with fadeIn:

.container {
    animation: fadeIn 0.5s;

@keyframes fadeIn {
    from {
        opacity: 0.25;
        transform: rotateY(-10deg);

    to {
        opacity: 1;
        transform: rotateY(0deg);
Enter fullscreen mode Exit fullscreen mode

As we can see with this simple @keyframes rule, we only slightly adjust the initial rotation and opacity for the element - you can choose whichever properties you like here but make sure it's not too much. Also, a snappy duration of 0.5s tends to work quite nicely.

That's it! Load up the page and see what it looks like 😁

Video Tutorial

If you prefer this tutorial in the form of video, check it out below on my YouTube channel, dcode.

Top comments (3)

matthijsewoud profile image

While this can look nice, I see websites overuse this a lot as well. Especially combined with scrolling.

I don’t feel it’s good UX to have to wait for the content to appear. It easily feels over designed when something is animating without being triggered by an interaction that warrants it.

dcodeyt profile image
Dom (dcode)

Can definitely agree with you there - this shouldn't be used as a work around to the core problem of slow load times.

Though I still think it has its place in more creative sites such as portfolios or art showcases/things of that nature.

jmr_code_social profile image
Jorge Marquez

Simple, clean and looks nice