Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8091701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:07:25+00:00 2026-06-05T20:07:25+00:00

I have a problem with jQuery parallax effect for my body’s background. Here is

  • 0

I have a problem with jQuery parallax effect for my body’s background. Here is the code:

jQuery(document).ready(function($){
    window.onscroll = function() {
        var bh = $(document.body).height();
        var wh = $(window).height();
        var st = $(window).scrollTop();
        var p = wh / bh;
        var pp = (st * p);
        $('body').css({backgroundPosition: '50% -'+pp+'px'});
    }

});

This code is great but after I have added I header with logo and nav menu they closed some part of background so not looks good enought now. Here is the link also http://layot.prestatrend.com/ The height of my header is 129px by the way. Seems I need to make background-position +129px but can’t figured out how to make it work properly with javascript. Any help please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:07:27+00:00Added an answer on June 5, 2026 at 8:07 pm

    just add here:

    var topPosition = pp + 129;
    $('body').css({backgroundPosition: '50% -'+topPosition +'px'});
    

    (or)

     $('body').css({backgroundPosition: '50% -'+ (pp + 129) +'px'}); // the parentesis avoid concatenation also
    

    this way you’ll properly add the offset you want. don’t do it inside the string concatenation because the browser might append ==> wich would cause something like: for pp=99 ==> pp+129 = '99129'.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with jQuery click event handling. Here's my code: $j(#btn_renommer_groupe).click(function(){ document.forms['creation_edition_groupe'].reset();
I have a problem with following jquery code if ($(window).scrollTop() >= ($(document).innerHeight() - $(window).innerHeight()))
I have a little problem with Jquery getJSON function. my json here { entries:
I have a problem using Jquery. I do this: $(#ID_ESTADO).change(function() { document.getElementById(inprogress).style.visibility = visible;
I have problem to add jQuery to some existing code, please help. We have
I have a problem with Jquery function getJSON, the action url does not trigger
I have the following code and I have problem with jQuery UI Slider. What
I have problem with call any jQuery function. The load is working, but when
I have a problem in my jquery code. I want to make a cascading
I have a problem with this jquery script. toggle:function() { if(this.opened){ $(slideToBuyBottomBtnClosed).setStyle(display,block); $(slideToBuyBottomBtnOpen).setStyle(display,none); $(sildeToBuyContent).setStyle(overflow,hidden);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.