Whenever you want to do animated scroll using a particular html element as a offset you can use the following jQuery code where -100 it the offset from the element in pixels.
1 |
jQuery(‘html, body’).animate({scrollTop:jQuery(‘#someid’).offset().top –100}, ‘slow’); |
Also if you would like to have the option for scrolling to the toп of your page use this one:
1 |
jQuery(‘html,body’).animate({ scrollTop: 0 }, ‘slow’); |