How to Create Animated Backgrounds on Web Pages

How to Create Animated Backgrounds on Web Pages

Animated backgrounds have become very popular in web design to welcome users in an impressive and interesting way. In this article, we will explain step by step how you can create animated backgrounds using CSS and HTML codes.

As the first step, we need to give a gradient effect to the background using CSS. In this way, our background will gain a more vibrant and eye-catching appearance. You can create a gradient background with the following CSS code:


    background: linear-gradient(to right, #ff7e5f, #feb47b);
  

In the next step, we need to define the animation that will make the background move. You can give a horizontal scroll effect to the background with the following CSS code:


    animation: scroll 20s linear infinite;
  

Now it's time to add this animated background to our web page using HTML codes. Here are the HTML codes:


    <div class="background"></div>
  

And finally, we need to define the CSS animation we created. We can create the scroll animation in the following CSS code:


    @keyframes scroll {
      0% {
        background-position: 0% 0%;
      }
      100% {
        background-position: 100% 0%;
      }
    }
  
You may be interested in the following articles;