skip to Main Content

I’m working on a responsive webpage and trying to add a smooth gradient animation to the background. On larger screens, the gradient animation works as expected, but when the screen width is below 900px, I can still clearly see the transition between colors, even though I have tried to make the animation as slow and subtle as possible.

Here’s the CSS I’m using for screens with a width below 900px:

 @media (max-width: 900px) {
  body {
    height: 100%;
    margin: 0;
    padding: 0;
    background: linear-gradient(300deg, #32de84, #4FFFB0);
    background-size: 200% 200%;
    animation: gradient-animation 200s ease-in-out infinite;
  }

  @keyframes gradient-animation {
    0% {
      background-position: 0% 50%;
    }
    50% {
      background-position: 100% 50%;
    }
    100% {
      background-position: 0% 50%;
    }
  }
}

Despite using a slow animation with a long duration (200s), the gradient movement is still very noticeable on mobile devices. I’ve also tried using background-attachment: fixed and reducing the background size further, but it didn’t fix the issue.

What am I missing, and how can I make the gradient animation less visible or even eliminate it entirely on smaller screens?

2

Answers


  1. You can try one of these solutions:

    1. Lowering the background size and slowing the animation can help minimize the visible transitions.
    2. Use a gradient with colors that are closer to each other in hue and brightness. This minimizes the perceived transition between colors.
    3. Use more subtle easing curves (e.g., cubic-bezier) for smoothness.
    4. Adding will-change: background-position; to the body can optimize rendering and smooth out animations.
    Login or Signup to reply.
  2. Apne website ko Google aur dusre search engines ke liye optimize karen. Iske liye keywords ka sahi istemal karna, meta tags aur high-quality content banana zaruri hai.

    Helpful tools:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search