0

i have a parallax that work with this function

var scaleBg = -$(window).scrollTop() / 3;
if (iOS === false) {
            $('.payoff').css('background-position-y', scaleBg - 150);
            $('.payoff2').css('background-position-y', scaleBg - 150);
            $('.social').css('background-position-y', scaleBg + 200);
        }

This not work on firefox becouse the background-position-y is not supported, how i can solve this for firefox?

1
  • I'd make it a 'normal' background-position and add the value for whatever has been set for the x-axis. Commented Apr 22, 2015 at 16:22

1 Answer 1

1

You need to use the combined background-position property such as:

var scaleBg = -$(window).scrollTop() / 3;
if (iOS === false) {
    var payoffY = scaleBg - 150;
    var payoff2Y = scaleBg - 150;
    var socialY = scaleBg + 200;
    $('.payoff').css('background-position', '0px ' + payoffY + 'px');
    $('.payoff2').css('background-position', '0px ' + payoff2Y + 'px');
    $('.social').css('background-position', '0px ' + socialY + 'px');
}

Just for reference here the + is for concatenation not addition. The 0 is what ever you need the x position of your background to be.

This should be a more cross browser compatible way of assigning background-position.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, now work. I was close to this solution, my mistake was to use scaleBg directly as y value, but did not work.
Glad it worked. If you are happy with the solution please select this as your accepted answer.

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.