動態移到某個捲軸的位置

摘要:動態移到某個捲軸的位置

很簡單,套用就好了,

<div id="scrollable" style="overflow: auto; height: 220px; width: 260px; border: 1px solid #000">


var targetOffset = $target.offset().top;
$('html,body').animate({scrollTop: targetOffset}, 1000);

$(document).ready(function() {
  $('#scrollit').click(function() {
    var divOffset = $('#scrollable').offset().top;
    var pOffset = $('#scrollable p:eq(2)').offset().top;
    var pScroll = pOffset - divOffset;
    $('#scrollable').animate({scrollTop: '+=' + pScroll + 'px'}, 1000, 'easeOutBounce');
  });
});

 

網頁設計 -->找網站銀行

好站推薦:網頁設計除臭襪