1

I'm using the following code to make the page smoothly scroll to the position 100px above an anchor:

$('html, body').stop().animate({
   'scrollTop': $target.offset().top-100
}, 500, 'swing', function () {
   window.location.hash = target;
   $(document).on("scroll", onScroll);
});

This code works on Chrome, but not on Firefox and Internet Explorer. It does smoothly scroll to the right position, but not 100px above it. Can someone explain to my why this is and if there's a way to fix this?

Here's a JSFiddle: https://jsfiddle.net/LLddrmmq/1/.

TheLeonKing
  • 3,501
  • 7
  • 32
  • 44

0 Answers0