问题
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