Bootstrap affix is always “jumping”

僤鯓⒐⒋嵵緔 提交于 2020-01-03 17:30:13

问题


I want to use the affix plugin of bootstrap on my sidebar. However, as my site is responsive, it's always jumping on some dimensions, and I can't get it working properly. I tried the solutions listed here: How to use the new affix plugin in twitter's bootstrap 2.1.0? but it's not just working.

Here's a demo

I know how I could do this on a site with fixed width, but as my site is responsive and so is bootstrap docs, and as it works perfectly there, how do I achieve the same effect?

As this isn't probably ever going to work

.affix {
    position: fixed; 
    top: 20px; 
    right: 10%;
}

回答1:


When I've used this, my .affix class just has position:fixed, nothing else. The top position at which the affix element becomes affixed can be set in the affix() method using the offset option, e.g.

$("#nav_id").affix({
    offset: 400
});


来源:https://stackoverflow.com/questions/13644266/bootstrap-affix-is-always-jumping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!