Search code examples
javascriptjqueryhtmlcsssmooth-scrolling

Smooth horizontal and vertical scrolling


I have started a website in which I need smooth horizontal and vertical scrolling. A menu on the right, so I can click the links to the different sections. I found some pretty useful codes and explanations of how to do it vertically. But I've been wondering, how could I do it horizontally without the use of plugins such as Fullpage.js?


Solution

  • Here is an example of how you can do horizontal smooth scrolling to the right when you click a button by using animate() method. Hope this can be useful.

        $(".downArrow").click(function () {
            var topPos = $('body').scrollTop();
            $("body").animate({
                scrollTop: topPos + 800
            }, 800);
        });