Animate scroll in the same page

SOLVE
Highlighted
New Contributor

Hi! 

 

Is there any possibility of doing a scroll animation on a link on the same page without jquery?

 

I use differents jquerys but none works. 

The html link is simple: 

 

Image with this link: https://www.adbarbieri.com/productos#enlace2

<a name="enlace2"></a>

 

I would like click in the image and make the animation scroll!

 

CSS
Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Highlighted
Solution
Regular Contributor

Hey @hernanmk,

 

Here's a smooth scrolling function I'm currently using:

 

 // Smooth Scrolling 
$(document).ready(function() {
$('a[href*=#]').bind('click', function(e) {
e.preventDefault();
var target = $(this).attr("href");
$('html, body').stop().animate({
scrollTop: $(target).offset().top-100
}, 500);
return false;
});
}); 

View solution in original post

3 Replies 3
Highlighted
Solution
Regular Contributor

Hey @hernanmk,

 

Here's a smooth scrolling function I'm currently using:

 

 // Smooth Scrolling 
$(document).ready(function() {
$('a[href*=#]').bind('click', function(e) {
e.preventDefault();
var target = $(this).attr("href");
$('html, body').stop().animate({
scrollTop: $(target).offset().top-100
}, 500);
return false;
});
}); 

View solution in original post

Highlighted
New Contributor

Thanks @MitchL 

 

Do I need to modify something or just copy it as it is and paste it at the end of my html?

Reply
0 Upvotes
Highlighted
Regular Contributor

It should just be good to go if you paste it in!

Reply
0 Upvotes