我有點新來的代碼,但當我嘗試使用jQuery腳本平滑滾動它從來沒有工作。jQuery的平滑滾動不能在我的網站上工作
如果我點擊我的按鈕它滾動到div,但不順利。
// Document ready shorthand statement
$(function() {
$('.link').click(function() {
var id = $(this).attr('href');
$('html,body').animate({
scrollTop: $(id).offset().top
}, 'slow');
// Prevent default behavior of link
return false;
});
});
#portfolio {/* just to make it visible */
margin-top: 100vh;
}
<a href="#portfolio"><button type="button" class="btn btn-lg btn-outline-info">Scroll down</button></a>
<div id="portfolio" class="container pt-5">
<div class="row d-flex justify-content-center">
<img id="thumb" src="images/img/01.jpg" class="img-thumbnail m-2 img-responsive" width="300" height="200">
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
只是一個小的事情 - 看我的答案......問候:) – Axel