Bootstrap:到达某个div的结尾时停止附加

Pie*_*ein 6 scroll twitter-bootstrap affix

滚动时我有一个侧边栏.现在我希望它在到达某个div时停止(并修复).

为了说明.发生了什么:http: //postimg.org/image/l1n0djb0n/

我想要的是:http: //postimg.org/image/5evr05x8n/

到达最后一个内容的底部时,我需要停止浮动(滚动).

我怎样才能做到这一点?

CSS:

#sidebar.affix-top {
position: static;
margin-top:0px; 
}

#sidebar.affix {
position: fixed;
top:49px;
}
Run Code Online (Sandbox Code Playgroud)

HTML:

 <div id="sidebar" class="sidebar_package">
 info for sidebar

 <div class="hiddenpackage_c2a">
     more content
 </div>

 </div>
Run Code Online (Sandbox Code Playgroud)

JS:

//Side menu floater
$('#sidebar').affix({
      offset: {
        //top: $('header').height()
        top:185
      }
});
Run Code Online (Sandbox Code Playgroud)

Kau*_*tuv 3

您可以使用底部偏移

$('#sidebar').affix({
    offset: {
       top: 180,
       bottom: $('#bottom-div').outerHeight(true)
   }
});
Run Code Online (Sandbox Code Playgroud)

并添加以下CSS

.affix-bottom { 
    position: absolute; 
}
Run Code Online (Sandbox Code Playgroud)