Scrolltop for fixed header page

Asked

Viewed 38 times

1

Good afternoon, I use the code below to go to the ID services below on the page:

<a class="ff" href="#" onclick="$('html,body').animate({scrollTop: $('#servicos').offset().top}, 500);">SERVIÇOS</a>

it works properly, but when I gave a position:fixed in the header, the service item is hidden below the header.. I was wondering if you could add the scrolltop + my header size (65px), like this: {scrollTop: $('#servicos').offset().top. + 65px}

Thank you!

1 answer

1


In fact it would be that without the point . after the top, and the value is negative, not positive. This should work by discounting the header size (no need to put the px)

{scrollTop: $('#servicos').offset().top - 65}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.