Reputation: 5241
I am using the following jQuery function to scroll to div IDs within a single page site:
$('a').click(function(){
var top = $('html').find($(this).attr('href')).offset().top;
$('html, body').animate({scrollTop: top},1500, 'easeInOutCubic');
return false;
});
Is there a way to add 100 pixels of space above each div using jQuery?
I have a fixed position menu in the top of the browser window and need the divs to remain below the menu when scrolled to.
Upvotes: 1
Views: 10105
Reputation: 1422
Not sure if I got the question right, but it sounds very easy to achieve:
...
var top = $('html').find($(this).attr('href')).offset().top - 100;
...
Upvotes: 9