以下のIDとスクロール機能のスクリプトを使用すると、簡単にターゲットまでスクロールできます。
<script>
$(document).ready(function(){
// Add smooth scrolling to all links
$("a").on('click', function(event) {
if (this.hash !== "") {
// Prevent default anchor click behavior
event.preventDefault();
var hash = this.hash;
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 800, function(){
// Add hash (#) to URL when done scrolling (default click behavior)
window.location.hash = hash;
});
}
});
});
</script>
あなただけ使用する他のページでセクションをターゲットにする場合、あなたは以下の構文
<a href="#section_target">Click Me to Smooth Scroll to Section Below</a>
を使用して#とのhrefを使用して必要なセクションにスクロールすることができますリンク先のターゲットセクションID
<a href="index.html#section_target">Take to target section in homepage</a>
ターゲットURL セクション同上これはあなたが探しているものである
希望とともに...
チェックこのことは https://www.w3schools.com/jquery/tryit.asp?filename=を助けている場合tryjquery_eff_animate_smoothscroll – amit77309