有人創建非常相似,你需要什麼樣的東西非常感謝,檢查出來:
jQuery.fn.extend({
scrollTo : function(speed, easing) {
return this.each(function() {
var targetOffset = $(this).offset().top;
$('html,body').animate({scrollTop: targetOffset}, speed, easing);
});
}
});
// Scroll to "about" section
$('#about').scrollTo('fast', 'linear');
JQUERY:
$('.next-section').click(function(){
var $this = $(this),
$next = $this.parent().next();
$next.scrollTo($next.offset().top, 500, 'linear');
});
$('.prev-section').click(function(){
var $this = $(this),
$prev = $this.parent().prev();
$prev.scrollTo($prev.offset().top, 500, 'linear');
});
HTML
<section id="about">
<a href="#" class="prev-section">Previous Section</a>
<a href="#" class="next-section">Next Section</a>
<div class="section-content">
Foobar
</div>
</section>
原貼:
Stackoverflow Original Post
jsfiddle
哪裏是你的代碼,你嘗試過什麼? – madalinivascu
對不起:(剛添加截圖。請現在檢查:) –
和你js,在一個更易於管理的格式 – madalinivascu