⇧
vadnica-logo
Editor My Blog Password Manager Finance My Services About the Project Telegram O meni O meni

CSS Animated Background - Dynamic Effects

Animated backgrounds are a great way to add dynamics to your website without overloading performance. In this example, you will learn how to create fluid gradient animations and interactive effects using pure CSS.

  • index.php
  • style.css
EXAMPLE
RESULT

Background with Animated Gradient

  1. The background is created using a linear color gradient, where colors transition between: lightblue -> lightyellow -> orange -> purple
  2. Gradient animation:
    1. using @keyframes gradientAnimation the background moves (in animation) by changing background-position
    2. animation makes the gradient "flow" from left to right and back
  3. The effect is achieved by:
    background-size: 200% 200%;
    animation: gradientAnimation 10s ease infinite;

Animated Container

  1. The .container element is designed as a box with rounded edges (border-radius), with shadows (box-shadow)
  2. Shadow animation (shadowChange):
    1. animation changes the shadow color around the element based on key frames (0% -> 100%)
    2. colors gradually change from blue, yellow, orange to purple:
    @keyframes shadowChange {
        0% {box-shadow: ... rgba(135, 206, 250, 0.5);} /* Blue shadow */
       25% {box-shadow: ... rgba(255, 255, 150, 0.5);} /* Yellow shadow */
       50% {box-shadow: ... rgba(255, 165, 0, 0.5);}   /* Orange shadow */
       75% {box-shadow: ... rgba(153, 101, 255, 0.5);} /* Purple shadow */
       100% {box-shadow: ... rgba(135, 206, 250, 0.5);} /* Back to blue */
    }

Modular Design

  1. html and body use a base gradient, without additional elements yet
  2. .container is the main dynamic element on the page, displayed in the center of the page and serves as the visual focal point.