1

I have a fixed position div which is controlled as such.

#backtoallprojects {
  float: none;
  position: fixed;
  top: 0px;
  right: 0px; 
  z-index:9999;
  background-color: rgba(0,0,0,0.5);
}

However, I only want it to reveal/appear after the page has been scrolled 95 pixels down.

This is because the main nav bar is 95px in height, and it is overlapping with other buttons, so should only reveal once the main nav has been scrolled out of the page.

Any help would be appreciated

Thanks

PS I have tried both these, but to no avail:

Show div after scrolling 100px from the top of the page

Show div on scrollDown after 800px

Community
  • 1
  • 1

2 Answers2

1

This worked for me:

$('#backtoallprojects').hide();
$(document).scroll(function() {
    if ($(document).scrollTop() >= 95) {
     $('#backtoallprojects').show();   
    }
    else {
        $('#backtoallprojects').hide();
    }
});

fiddle: http://jsfiddle.net/ray9209/kayweuyp/1/

ray9209
  • 388
  • 3
  • 14
0

thanks for your answers. The jQuery script did work, it turns out I had to change the way it was being added to my Wordpress theme.

I needed to use "noconflict mode", so instead of $ use jQuery for the function names.

  • You could wrap your code inside something like `(function($){ ..your code..})(jQuery)` to keep using $ – René Oct 30 '14 at 08:52