Search code examples
jquerynavigationoffsetfixedscrollto

jQuery scrollTo offset height


I have a website with a static (fixed) top navigation. Because of the scrollto I need to specify a offset of 100px, but I really don't know how to change it in this line:

<a class="current link1" onClick="$('#home').ScrollTo();">Home</a>

I allready tried things like this, but it isn't working:

 <a class="current link1" onClick="$('#home').ScrollTo(offset: -100);">Home</a>

 <a class="current link1" onClick="$('#home').ScrollTo({offset: -100});">Home</a>

Preview: http://www.pandamedia.nl/vb


Solution

  • you can try this

    <a class="current link1" onClick="$('html, body').animate({ scrollTop: Math.round(parseFloat($('#home').offset().top)) - 100 }, 400);">Home</a>