2

I have a div with a background that has both a background image that's a transparent png and a linear-gradient. The desired effect is to have the image animate while the gradient remains static. In Chrome and Safari this is how the animation works but in Firefox and IE both the background image and the gradient animate together.

Is there a way to get the desired effect in all browsers using CSS without adding another div?

http://jsfiddle.net/FprGA/

    @-webkit-keyframes bgscroll {
  0% { background-position: 0 0 ; }
  100% { background-position: 0 -230px; }
}

@keyframes bgscroll {
  0% { background-position: 0 0 ; }
  100% { background-position: 0 -230px; }
}

  .hero {
    display: block;
    height: 20rem;
    background-image: image-url("icons_grid.png"), -webkit-linear-gradient(to bottom, #646464, #323232);
    background-image: image-url("icons_grid.png"), -moz-linear-gradient(to bottom, #646464, #323232);
    background-image: image-url("icons_grid.png"), linear-gradient(to bottom, #646464, #323232);
    margin-bottom: 3rem;
    animation: bgscroll 30s infinite linear;
    -webkit-animation: bgscroll 30s infinite linear;
    border-bottom: .3rem solid #0b71b9;
  }

1 Answer 1

5

This did the job for me:

@keyframes bgscroll {
  0% { background-position: 0 0, 0 ; }
  100% { background-position: 0 -230px, 0; }  // added '0' position for 2nd background
}
Sign up to request clarification or add additional context in comments.

2 Comments

Glad that I could help :)
Yes confirmed on my end as well. Thank you very much, it's working in all browsers as expected now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.