A
A
asosonko42017-01-18 14:48:06
css
asosonko4, 2017-01-18 14:48:06

Is it possible to animate scroll to anchor with jquery without using $('html, body') and third party plugins?

The structure of my project requires that <body>and <html>always have ovreflow:hidden. The main child-container #main-wrapperhas overflow-y: scrolland I'm making every effort to make the scroll animation in this container. However, it turns out that it is $('#my_element').offset().topalways different. Being at the very top of the page and pressing the button - #main-wrapperit scrolls smoothly. We go down a little while the button is still in view, click on it and the scroll already works incorrectly due to an incorrect $('#my_element').offset().top.

Here is a sample code.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
justdealman, 2017-01-18
@asosonko4

Add content wrapper:
https://jsfiddle.net/nevcn3vo/15/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question