jQuery Smooth Scrolling
HTML
<html>
<body>
<a href="#bottom" id="top">nach unten</a>
<p>hier</p>
<p>funktioniert</p>
<p>es</p>
<a href="#top" id="bottom">nach oben</a>
</body>
</html>
CSS
html {
font-size: 20px;
text-align: center;
}
p {
padding: 200px 0;
}
JavaScript
$(document).ready(function() {
$('a[href^="#"]').on('click', function(e) {
e.preventDefault();
var target = this.hash;
var $target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 900, 'swing', function() {
window.location.hash = target;
});
});
});