jQuery scrollTo fixed header offset

Tom picture Tom · Jun 13, 2012 · Viewed 29k times · Source

I am using the jQuery scrollTo plugin as you can see on the page which I'm building http://portfolio.tomvervoort.net/

Because of the 300px fixed header the content moves under the header. You can see this clearly when you click the about button in the menu. Is it possible to add an 300px offset to the scrollTo script so everything stays positioned under the header/menu?

Answer

Andy picture Andy · Jun 13, 2012

You could try changing this line in jquery.nav.js:

$.scrollTo(newLoc, o.scrollSpeed, {

to

$.scrollTo($('newLoc').offset().top-300, o.scrollSpeed, { 

So instead of telling scrollto to scroll to exactly that element, you get the position of the element yourself and subtract 300