2014-07-15 88 views
0

我已經使用平滑滾動插件從CSS技巧, 它的工作很好,但只有2 ancoher鏈接,而不是一個又一個,請在這裏看到演示,平滑滾動跳躍而不是滾動

LIVE DEMO

它的工作非常適合行業和定價,但在證明書中,它只是跳到位置,固定導航也截斷了該部分。

<script> 
$(document).ready(function() { 
    $('a[href^="#"]').on('click', function (e) { 
     e.preventDefault(); 
     var target = this.hash, 
      $target = $(target); 
     $('html, body').stop().animate({ 
      'scrollTop': $target.offset().top - 130 // - 130px (nav-height) 
     }, 900, 'swing', function() { 
      // Replace this with something that can be easily parsed and used by your code 
      window.location.hash = '3' + target; 
     }); 
    }); 
}); 
</script> 

回答

1

這裏,我已經做了的jsfiddle,
jsfiddle.net/Thq62/

和它的正常工作只是增加了一個正確的ID和散列鏈接

+0

添加了完美的標識和散列到鏈接,但仍然不能正常工作 –

+0

我可以看到一個示例代碼? –