Azeem Haider Azeem Haider - 1 day ago 4
HTML Question

need java script for smooth scroll down

I have navigation bar working with css id.
When i click on button it suddenly took me to that id.
I want a smooth scroll to that id. How it is possible.
Please help me.

Answer

With jQuery you can simply use the animate function

Example:

$('html, body').animate({
    scrollTop: $('#button_id').offset().top // scroll down to button
  }, 500); // scrolls smoothly in 500 milliseconds
Comments