twitter-bootstrap 在滚动上取消固定 Twitter 引导程序的词缀
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13417818/
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
Unpin Twitter bootstrap's affix on scroll
提问by Fernanda Parisi
I'm using Twitter bootstrap's affix on a sidebar, on a traditional website layout (header -content and sidebar - footer).
我在侧边栏上使用 Twitter 引导程序的词缀,在传统的网站布局(页眉 - 内容和侧边栏 - 页脚)。
On a certain scroll point I want it to unpin from the page and return to it's original position:static, so it doesn't overlap the footer. I was trying to fiddle it around only with CSS, but since the .affix sets the element position as fixed it messes up the sidebar height.
在某个滚动点上,我希望它从页面上取消固定并返回到它的原始位置:静态,因此它不会与页脚重叠。我试图只用 CSS 来摆弄它,但是由于 .affix 将元素位置设置为固定的,它弄乱了侧边栏的高度。
I'm thinking it has something to do with JS, maybe removing the affix class. Any solutions/suggestions?
我认为它与JS有关,也许删除了词缀类。任何解决方案/建议?
回答by noitseuq
Use data-offset-bottomproperty for this purpose:
data-offset-bottom为此目的使用财产:
<div class="sidebar" data-spy="affix" data-offset-top="50" data-offset-bottom="300">
Sidebar
</div>
Here is the example: http://jsfiddle.net/NwwKQ/120/

