Onclick menu button, website scrolls to div
12,189
Solution 1
For something really basic use this:
<a href="#work">Work</a>
or you can try jQuery plugin ScrollTo
Solution 2
If your Work section have a id, for instance work
you can do it with:
$('html, body').animate({scrollTop: $("#work").offset().top}, 2000);
with some smooth animation
Author by
Admin
Updated on June 16, 2022Comments
-
Admin almost 2 years
I'm making a personal portfolio in an infinte scroll website. Right now I have 4 divs (home, bio, work and contact). I have an header with a menu with 4 names, same as divs. So what I want to do is to have a trigger when I'm at the div "Home" and click on the menu "Work" I want the browser to scroll down to the third div whick is "Work". Hope I make myself clear :)
-
Admin about 10 yearsthat code just opens a blank page. About the ScrollTo plugin, I have no clue how to use it.
-
Jatin about 10 yearsit doesn't open a blank page. It scrolls down to that page.
-
Jatin about 10 yearsFor complete example You can hav a look at insitedesignlab.com/how-to-make-a-single-page-website
-
Admin about 10 yearsIt's working thank you, I'm new so, I messed up with the tags, now I just need an animation.
-
Admin about 10 yearsWhere do I paste this?!
-
Jatin about 10 yearsGlad that i could help you.
-
Admin about 10 yearsdo you know how to make the animation that pna posted?
-
Jatin about 10 yearsAre you talking about smooth scroll if yes then refer insitedesignlab.com/how-to-make-a-single-page-website
-
Jatin over 9 yearsThats Nice...All Good Np :)