スポンサーリンク

固定されたヘッダーのアンカーリンクに最適「smooth-scroll.js」

jQuery

■GitHubでダウンロード

GitHub - cferdinandi/smooth-scroll: A lightweight script to animate scrolling to anchor links.
A lightweight script to animate scrolling to anchor links. - GitHub - cferdinandi/smooth-scroll: A lightweight script to animate scrolling to anchor links.

 

html

<script src="js/smooth-scroll.polyfills.min.js"></script>

 

js

<script>
var scroll = new SmoothScroll('a[href*="#"]');
<script>

 

ヘッダーを固定している場合のずれ

<script>
var scroll = new SmoothScroll('a[href*="#"]', {
  header: '#header'
});
</script>

 

スクロールスピードの調整

<script>
var scroll = new SmoothScroll('a[href*="#"]', {
  header: '#header',
  speed: 1000,
});
</script>

 

タイトルとURLをコピーしました