html - jquery animate a scroll but not on exact position where the id is since my nav is fixed at the top -


basically 1 page site fixed header nav on top has height , cover top portion when scrolled down or clicked nav. here jquery script got here well

$(document).ready(function() { $('ul.navigation').on('click', 'a', function(e) {              e.preventdefault();       $('html, body').animate({         scrolltop: $( $.attr(this, 'href') ).offset().top       }, 2000);    }); }); 

all except when click on nav scrolls on specific id ofcourse element has id, example h1, being covered header since header positioned @ top of page. how can adjust , @ least add 185px, size of fixed header, on scroll animation ids positioned. many thanks!

just update script add space...

$('html, body').animate({     scrolltop: ($( $.attr(this, 'href') ).offset().top - 185)   }, 2000); 

here's example fiddle related question


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -