2011-08-11 121 views
0

嗨,大家好,我一直试图让我的锚在平稳的滚动工作了很长时间,但永远无法做到正确。工作滚动锚

我试过ifxscrollto插件,它只是平坦的不会为我和其他人工作....任何人都有建议吗?

PS:我想要一个自动抓取命名锚的脚本。

+0

或类似的东西http://djpate.com/portfolio/jSlideto/example/index.html http://css-tricks.com/snippets/jquery/smooth-scrolling/ – zod

回答

0

这很难理解你要求什么。这样的事情可能吗?

http://beski.wordpress.com/2009/04/21/scroll-effect-with-local-anchors-jquery/

+0

谢谢...修改脚本因此它会自动生成本地锚,而不会应用类$(document).ready(function(){('a [href^=“#”]')。click(function(event){\t \t \t event。的preventDefault(); \t变种full_url = this.href; \t \t变种份= full_url.split( “#”); \t \t变种TRGT =份[1]; \t \t var target_offset = $(“#”+ trgt).offset(); \t \t var target_top = target_offset.top; $('html,body')。animate({scrollTop:target_top},500); \t}); });' –

0

没有确切的代码,但会像这样的工作,如果我理解正确的话你的问题:

$("#mn a").click(function(){ 
     var aTarget = $(this).attr("href"); 
     $('html, body').animate({scrollTop: $(aTarget).offset().top}, 800); 
     return false; 
    }); 

这是我在我的网站上使用,从一个a具有平滑滚动div的ID为(a's)href的值。