Parallax Feature is splitting my image in two vertical halves










-1















I have ran into a crazy issue: my parallax effect is going bonkers.



When I don't have the background-repeat on I get a white space of about 200px above the image, if the background-repeat is on, my image is repeated in that space above.



I don't know how else to explain this.

When I refresh the page, the image is in its appropriate place, but as soon as there is a scroll event, the image bounces down and has that extra space on top.



I've tried various things with both the CSS and the JQuery to no avail. I sure hope one of you experts have an answer to this mess.



I have a Codepen at https://codepen.io/eghoff/pen/MzbLBo but it won't show the refresh as I've explained it.



For that you can go here: https://agilewebsitedesigns.co.uk/indexHome.html



Thanks for any and all help.






$(window).scroll(function() 

parallax();

);

function parallax()

var wScroll = $(window).scrollTop();

$('.parallax--bg').css('background-position', 'center ' + (wScroll * 0.250) + 'px');

$('.parallax--box').css('top', -5 + (wScroll * 0.0125) + 'em');

.sliderContainer 
background-color: white;
background-image: url("../images/001-homepage-images/slider.jpg");
height: 800px;
background-position: center;
background-size: cover;
width: 80%;
margin: 0 auto;
padding: 0;


.parallax--bg,
.parallax--box
transition: initial;


.parallax-curtain
height: 650px;
padding-top: 125px;
background: rgba(255, 255, 255, 0.0);


.pTextContainer
width: 100%;
height: 400px;
background: transparent;
text-align: center;


.pText h3
font-size: 2em;
color: white;
margin: 0 auto;
padding-top: 2em;

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section>
<div class="sliderContainer parallax--bg">
<div class="parallax-curtain">
<div class="pTextContainer">
<div class="pText">
<h3>Knowing when you need help is a big thing</h3>
<h3>Finding the right help can be a daunting task</h3>
<h3>I am here to help you</h3>
</div>
</div>
</div>
</div>

</section>












share|improve this question




























    -1















    I have ran into a crazy issue: my parallax effect is going bonkers.



    When I don't have the background-repeat on I get a white space of about 200px above the image, if the background-repeat is on, my image is repeated in that space above.



    I don't know how else to explain this.

    When I refresh the page, the image is in its appropriate place, but as soon as there is a scroll event, the image bounces down and has that extra space on top.



    I've tried various things with both the CSS and the JQuery to no avail. I sure hope one of you experts have an answer to this mess.



    I have a Codepen at https://codepen.io/eghoff/pen/MzbLBo but it won't show the refresh as I've explained it.



    For that you can go here: https://agilewebsitedesigns.co.uk/indexHome.html



    Thanks for any and all help.






    $(window).scroll(function() 

    parallax();

    );

    function parallax()

    var wScroll = $(window).scrollTop();

    $('.parallax--bg').css('background-position', 'center ' + (wScroll * 0.250) + 'px');

    $('.parallax--box').css('top', -5 + (wScroll * 0.0125) + 'em');

    .sliderContainer 
    background-color: white;
    background-image: url("../images/001-homepage-images/slider.jpg");
    height: 800px;
    background-position: center;
    background-size: cover;
    width: 80%;
    margin: 0 auto;
    padding: 0;


    .parallax--bg,
    .parallax--box
    transition: initial;


    .parallax-curtain
    height: 650px;
    padding-top: 125px;
    background: rgba(255, 255, 255, 0.0);


    .pTextContainer
    width: 100%;
    height: 400px;
    background: transparent;
    text-align: center;


    .pText h3
    font-size: 2em;
    color: white;
    margin: 0 auto;
    padding-top: 2em;

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <section>
    <div class="sliderContainer parallax--bg">
    <div class="parallax-curtain">
    <div class="pTextContainer">
    <div class="pText">
    <h3>Knowing when you need help is a big thing</h3>
    <h3>Finding the right help can be a daunting task</h3>
    <h3>I am here to help you</h3>
    </div>
    </div>
    </div>
    </div>

    </section>












    share|improve this question


























      -1












      -1








      -1








      I have ran into a crazy issue: my parallax effect is going bonkers.



      When I don't have the background-repeat on I get a white space of about 200px above the image, if the background-repeat is on, my image is repeated in that space above.



      I don't know how else to explain this.

      When I refresh the page, the image is in its appropriate place, but as soon as there is a scroll event, the image bounces down and has that extra space on top.



      I've tried various things with both the CSS and the JQuery to no avail. I sure hope one of you experts have an answer to this mess.



      I have a Codepen at https://codepen.io/eghoff/pen/MzbLBo but it won't show the refresh as I've explained it.



      For that you can go here: https://agilewebsitedesigns.co.uk/indexHome.html



      Thanks for any and all help.






      $(window).scroll(function() 

      parallax();

      );

      function parallax()

      var wScroll = $(window).scrollTop();

      $('.parallax--bg').css('background-position', 'center ' + (wScroll * 0.250) + 'px');

      $('.parallax--box').css('top', -5 + (wScroll * 0.0125) + 'em');

      .sliderContainer 
      background-color: white;
      background-image: url("../images/001-homepage-images/slider.jpg");
      height: 800px;
      background-position: center;
      background-size: cover;
      width: 80%;
      margin: 0 auto;
      padding: 0;


      .parallax--bg,
      .parallax--box
      transition: initial;


      .parallax-curtain
      height: 650px;
      padding-top: 125px;
      background: rgba(255, 255, 255, 0.0);


      .pTextContainer
      width: 100%;
      height: 400px;
      background: transparent;
      text-align: center;


      .pText h3
      font-size: 2em;
      color: white;
      margin: 0 auto;
      padding-top: 2em;

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
      <section>
      <div class="sliderContainer parallax--bg">
      <div class="parallax-curtain">
      <div class="pTextContainer">
      <div class="pText">
      <h3>Knowing when you need help is a big thing</h3>
      <h3>Finding the right help can be a daunting task</h3>
      <h3>I am here to help you</h3>
      </div>
      </div>
      </div>
      </div>

      </section>












      share|improve this question
















      I have ran into a crazy issue: my parallax effect is going bonkers.



      When I don't have the background-repeat on I get a white space of about 200px above the image, if the background-repeat is on, my image is repeated in that space above.



      I don't know how else to explain this.

      When I refresh the page, the image is in its appropriate place, but as soon as there is a scroll event, the image bounces down and has that extra space on top.



      I've tried various things with both the CSS and the JQuery to no avail. I sure hope one of you experts have an answer to this mess.



      I have a Codepen at https://codepen.io/eghoff/pen/MzbLBo but it won't show the refresh as I've explained it.



      For that you can go here: https://agilewebsitedesigns.co.uk/indexHome.html



      Thanks for any and all help.






      $(window).scroll(function() 

      parallax();

      );

      function parallax()

      var wScroll = $(window).scrollTop();

      $('.parallax--bg').css('background-position', 'center ' + (wScroll * 0.250) + 'px');

      $('.parallax--box').css('top', -5 + (wScroll * 0.0125) + 'em');

      .sliderContainer 
      background-color: white;
      background-image: url("../images/001-homepage-images/slider.jpg");
      height: 800px;
      background-position: center;
      background-size: cover;
      width: 80%;
      margin: 0 auto;
      padding: 0;


      .parallax--bg,
      .parallax--box
      transition: initial;


      .parallax-curtain
      height: 650px;
      padding-top: 125px;
      background: rgba(255, 255, 255, 0.0);


      .pTextContainer
      width: 100%;
      height: 400px;
      background: transparent;
      text-align: center;


      .pText h3
      font-size: 2em;
      color: white;
      margin: 0 auto;
      padding-top: 2em;

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
      <section>
      <div class="sliderContainer parallax--bg">
      <div class="parallax-curtain">
      <div class="pTextContainer">
      <div class="pText">
      <h3>Knowing when you need help is a big thing</h3>
      <h3>Finding the right help can be a daunting task</h3>
      <h3>I am here to help you</h3>
      </div>
      </div>
      </div>
      </div>

      </section>








      $(window).scroll(function() 

      parallax();

      );

      function parallax()

      var wScroll = $(window).scrollTop();

      $('.parallax--bg').css('background-position', 'center ' + (wScroll * 0.250) + 'px');

      $('.parallax--box').css('top', -5 + (wScroll * 0.0125) + 'em');

      .sliderContainer 
      background-color: white;
      background-image: url("../images/001-homepage-images/slider.jpg");
      height: 800px;
      background-position: center;
      background-size: cover;
      width: 80%;
      margin: 0 auto;
      padding: 0;


      .parallax--bg,
      .parallax--box
      transition: initial;


      .parallax-curtain
      height: 650px;
      padding-top: 125px;
      background: rgba(255, 255, 255, 0.0);


      .pTextContainer
      width: 100%;
      height: 400px;
      background: transparent;
      text-align: center;


      .pText h3
      font-size: 2em;
      color: white;
      margin: 0 auto;
      padding-top: 2em;

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
      <section>
      <div class="sliderContainer parallax--bg">
      <div class="parallax-curtain">
      <div class="pTextContainer">
      <div class="pText">
      <h3>Knowing when you need help is a big thing</h3>
      <h3>Finding the right help can be a daunting task</h3>
      <h3>I am here to help you</h3>
      </div>
      </div>
      </div>
      </div>

      </section>





      $(window).scroll(function() 

      parallax();

      );

      function parallax()

      var wScroll = $(window).scrollTop();

      $('.parallax--bg').css('background-position', 'center ' + (wScroll * 0.250) + 'px');

      $('.parallax--box').css('top', -5 + (wScroll * 0.0125) + 'em');

      .sliderContainer 
      background-color: white;
      background-image: url("../images/001-homepage-images/slider.jpg");
      height: 800px;
      background-position: center;
      background-size: cover;
      width: 80%;
      margin: 0 auto;
      padding: 0;


      .parallax--bg,
      .parallax--box
      transition: initial;


      .parallax-curtain
      height: 650px;
      padding-top: 125px;
      background: rgba(255, 255, 255, 0.0);


      .pTextContainer
      width: 100%;
      height: 400px;
      background: transparent;
      text-align: center;


      .pText h3
      font-size: 2em;
      color: white;
      margin: 0 auto;
      padding-top: 2em;

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
      <section>
      <div class="sliderContainer parallax--bg">
      <div class="parallax-curtain">
      <div class="pTextContainer">
      <div class="pText">
      <h3>Knowing when you need help is a big thing</h3>
      <h3>Finding the right help can be a daunting task</h3>
      <h3>I am here to help you</h3>
      </div>
      </div>
      </div>
      </div>

      </section>






      jquery css parallax






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 4:18









      Adriano

      1,34911324




      1,34911324










      asked Nov 13 '18 at 0:43









      rocknriterrocknriter

      108




      108






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Your image is offset from the top of the page by about 1000px, meaning by the time you actually scroll to it, the scrollTop() is 1000px. Your calculation results in a background-position of center 250px. The 250px is the whitespace you're seeing.



          To account for this, you could do something like offset().top - scrollTop(). This ensures that by the time you've scrolled down to the image, the background-position will be roughly center 0px.



          function parallax() 
          var $parallaxBg = $('.parallax--bg');
          var wScroll = $(window).scrollTop();
          var wOffset = $parallaxBg.offset().top;
          var wBackgroundPos = (wScroll-wOffset) * 0.250;

          $parallaxBg.css('background-position', 'center ' + wBackgroundPos + 'px');
          $('.parallax--box').css('top', -5 + (wScroll * 0.0125) + 'em');



          Here's an updated version of your codepen.






          share|improve this answer

























          • Thank you, Tyler Roper. This works great!! :)

            – rocknriter
            Nov 13 '18 at 4:14










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53272161%2fparallax-feature-is-splitting-my-image-in-two-vertical-halves%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Your image is offset from the top of the page by about 1000px, meaning by the time you actually scroll to it, the scrollTop() is 1000px. Your calculation results in a background-position of center 250px. The 250px is the whitespace you're seeing.



          To account for this, you could do something like offset().top - scrollTop(). This ensures that by the time you've scrolled down to the image, the background-position will be roughly center 0px.



          function parallax() 
          var $parallaxBg = $('.parallax--bg');
          var wScroll = $(window).scrollTop();
          var wOffset = $parallaxBg.offset().top;
          var wBackgroundPos = (wScroll-wOffset) * 0.250;

          $parallaxBg.css('background-position', 'center ' + wBackgroundPos + 'px');
          $('.parallax--box').css('top', -5 + (wScroll * 0.0125) + 'em');



          Here's an updated version of your codepen.






          share|improve this answer

























          • Thank you, Tyler Roper. This works great!! :)

            – rocknriter
            Nov 13 '18 at 4:14















          0














          Your image is offset from the top of the page by about 1000px, meaning by the time you actually scroll to it, the scrollTop() is 1000px. Your calculation results in a background-position of center 250px. The 250px is the whitespace you're seeing.



          To account for this, you could do something like offset().top - scrollTop(). This ensures that by the time you've scrolled down to the image, the background-position will be roughly center 0px.



          function parallax() 
          var $parallaxBg = $('.parallax--bg');
          var wScroll = $(window).scrollTop();
          var wOffset = $parallaxBg.offset().top;
          var wBackgroundPos = (wScroll-wOffset) * 0.250;

          $parallaxBg.css('background-position', 'center ' + wBackgroundPos + 'px');
          $('.parallax--box').css('top', -5 + (wScroll * 0.0125) + 'em');



          Here's an updated version of your codepen.






          share|improve this answer

























          • Thank you, Tyler Roper. This works great!! :)

            – rocknriter
            Nov 13 '18 at 4:14













          0












          0








          0







          Your image is offset from the top of the page by about 1000px, meaning by the time you actually scroll to it, the scrollTop() is 1000px. Your calculation results in a background-position of center 250px. The 250px is the whitespace you're seeing.



          To account for this, you could do something like offset().top - scrollTop(). This ensures that by the time you've scrolled down to the image, the background-position will be roughly center 0px.



          function parallax() 
          var $parallaxBg = $('.parallax--bg');
          var wScroll = $(window).scrollTop();
          var wOffset = $parallaxBg.offset().top;
          var wBackgroundPos = (wScroll-wOffset) * 0.250;

          $parallaxBg.css('background-position', 'center ' + wBackgroundPos + 'px');
          $('.parallax--box').css('top', -5 + (wScroll * 0.0125) + 'em');



          Here's an updated version of your codepen.






          share|improve this answer















          Your image is offset from the top of the page by about 1000px, meaning by the time you actually scroll to it, the scrollTop() is 1000px. Your calculation results in a background-position of center 250px. The 250px is the whitespace you're seeing.



          To account for this, you could do something like offset().top - scrollTop(). This ensures that by the time you've scrolled down to the image, the background-position will be roughly center 0px.



          function parallax() 
          var $parallaxBg = $('.parallax--bg');
          var wScroll = $(window).scrollTop();
          var wOffset = $parallaxBg.offset().top;
          var wBackgroundPos = (wScroll-wOffset) * 0.250;

          $parallaxBg.css('background-position', 'center ' + wBackgroundPos + 'px');
          $('.parallax--box').css('top', -5 + (wScroll * 0.0125) + 'em');



          Here's an updated version of your codepen.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 13 '18 at 3:23

























          answered Nov 13 '18 at 3:18









          Tyler RoperTyler Roper

          13.6k31841




          13.6k31841












          • Thank you, Tyler Roper. This works great!! :)

            – rocknriter
            Nov 13 '18 at 4:14

















          • Thank you, Tyler Roper. This works great!! :)

            – rocknriter
            Nov 13 '18 at 4:14
















          Thank you, Tyler Roper. This works great!! :)

          – rocknriter
          Nov 13 '18 at 4:14





          Thank you, Tyler Roper. This works great!! :)

          – rocknriter
          Nov 13 '18 at 4:14

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53272161%2fparallax-feature-is-splitting-my-image-in-two-vertical-halves%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Use pre created SQLite database for Android project in kotlin

          Darth Vader #20

          Ondo