简体   繁体   English

HTML锚链接-偏移位置

[英]HTML Anchor Link - Offseting Position

I have Created an Example Page Below: 我在下面创建了一个示例页面:
http://glustik.com/glustik2/index.html http://glustik.com/glustik2/index.html

When you Click the First Two Links you can see how the Anchors Position to the top and not down (250 or so Pixels). 当您单击前两个链接时,您可以看到锚点如何定位到顶部而不是向下(大约250个像素)。

Is there a way to summon the anchors to a certain location on the window? 有没有一种方法可以将锚点召唤到窗户上的某个位置?

Thanks. 谢谢。

您可以使用jQuery动画函数将scrollTop设置到所需位置。

$("html, body").animate({ scrollTop: $("#your-div").offset().top - YourHeadersHeight }, 500);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM