how do I define where my scroll animation(jquery) should end up as a string on the page

Asked

Viewed 58 times

0

Hello, I would like to know how to define a location where the scroll effect of site one page should stop. The problem I face is that by clicking on one of the links in my navigation menu in the header the automatic scroll moves to the desired content but cuts parts of it as the title of the content, as I define where it should stop.

O click no link do conteudo

O erro

O resultado desejado

I ask you to observe carefully as it is a well-crafted question.

  • It happens because of you navbar is with posítion:fixed post your complete code that makes it easier to help you.

1 answer

0

In the final position that you pass to the function of Animate, you need to subtract the height of this fixed header. That is, the coordinate will be the placeDoConference - highDoHeader.

For example:

$("html, body").animate({ 
    scrollTop: $(#sobre-nos).offset().top - $('#topo').outerHeight() 
}, 1000);
  • I’ll test you if it works

  • jQuery(Document). ready(Function($) { $(". scroll"). click(Function(Event)' Event.preventDefault(); $('html,body'). Animate({scrollTop:$(this.hash). offset(). top}, 1000); }); });

  • this and the code

  • where should I make the change

  • {scrollTop:$(this.hash).offset().top - 100}, Exchange "100" for header height.

  • Thank you so much you helped me so much I would have to go over a lot of things to find that our kkk was slow I didn’t notice a simple thing like this

Show 1 more comment

Browser other questions tagged

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