twitter-bootstrap Bootstrap 并跳转到 Anchors
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14068203/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bootstrap and jumping to Anchors
提问by Bruce
I'm building a quick VPS main page for my dev server using bootstrap ( still learning ). But I cant get the anchors to line up to the top. I searched 2 hours about using bootstrap and different plugins to get the same effect as: http://twitter.github.com/bootstrap/components.html
我正在使用引导程序(仍在学习)为我的开发服务器构建一个快速的 VPS 主页。但我无法让锚排到顶部。我搜索了 2 个小时关于使用引导程序和不同的插件以获得与以下相同的效果:http: //twitter.github.com/bootstrap/components.html
When you chose a menu item on the left the page automatically scrolles down. And the anchor is aligned to the top. I think this is done with jQuery but I can't figure out how. My links do jump to the anchors but just barely so that they are visible.
当您选择左侧的菜单项时,页面会自动向下滚动。并且锚点与顶部对齐。我认为这是用 jQuery 完成的,但我不知道怎么做。我的链接确实跳转到锚点,但只是勉强使它们可见。
Can anyone tell me how this is achieved ?
谁能告诉我这是如何实现的?
回答by Bruce
Assuming you're using a fixed nav bar, you need to add the same padding-top you have in body (to accomodate the nav bar) to the element you're anchoring too.
假设您使用的是固定导航栏,您需要将与 body 相同的 padding-top(以容纳导航栏)添加到您锚定的元素中。
I found this article that explained it quite well here: http://www.servermule.com.au/help/bootstrap-anchors-fixed-nav/
我发现这篇文章在这里解释得很好:http: //www.servermule.com.au/help/bootstrap-anchors-fixed-nav/
回答by Jason Towne
I believe they are using the Affix plugin.
我相信他们正在使用Affix 插件。

