Get started with smooth-scroll CDN
Stable version
Copied!
How to start using smooth-scroll CDN
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
<script src="https://cdn.cdnhub.io/smooth-scroll/16.1.3/smooth-scroll.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const links = document.querySelectorAll('a[href^="#"]');
links.forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
smoothScroll.animateScroll(target.offsetTop, 500);
});
});
});
</script>
</head>
<body>
<header>
<nav>
<ul>
<li><a href="#about">About</a></li>
<li><a href="#services">Services</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<main id="about">
<!-- Content about section -->
</main>
<main id="services">
<!-- Content services section -->
</main>
<main id="contact">
<!-- Content contact section -->
</main>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
All versions
10.0.0
10.0.1
10.1.0
10.2.0
10.2.1
10.3.1
11.0.0
11.0.1
11.0.2
11.1.0
12.0.0
12.1.0
12.1.1
12.1.2
12.1.3
12.1.4
12.1.5
14.0.0
14.0.1
14.1.0
14.1.1
14.2.0
14.2.1
15.0.0
15.0.1
15.1.0
15.1.1
15.1.2
15.1.3
15.2.0
15.2.1
16.0.1
16.0.2
16.0.3
16.1.0
16.1.1
16.1.2
*** 16.1.3
2.0.2
4.8.2
5.0.0
5.0.1
5.0.4
5.1.0
5.1.4
5.2.0
5.3.3
5.3.6
5.3.7
6.0.0
7.0.0
7.0.1
7.0.2
7.1.0
7.1.1
8.0.0
8.1.0
9.0.0
9.0.1
9.1.0
9.1.1
9.1.2
9.1.3
9.1.4
9.2.0
9.3.0
9.3.1
9.3.2
9.4.1
9.4.2
9.4.3