html - jQuery Horizontal Scroll to DIV on Click -
i have parallax setup user can scroll down when on landing of site. once scroll down, can scroll across different pages.
i have tried using jquery code:
$("#scrollto").click(function() { $('html, body').animate({ scrolltop: $("#page2").offset().top }, 2000);
});
i want make when user clicks button scrolls across or horizontally second page "view2". system not seem work.
here fiddle: https://jsfiddle.net/qm7s60ud/1/
the animate should on .wrapper
class since element has overflow.
.wrapper { height: 100%; background-color: gray; overflow: auto; //overflow causes div have scroll bar }
and instead of scrolltop
, .offset().top
, (because vertical)
it should be scrollleft
, .offset().left
.. (this horizontal)
Comments
Post a Comment