【问题标题】:Bootstrap: Stop affix when reaching end of certain divBootstrap:到达某个 div 的末尾时停止词缀
【发布时间】:2015-08-07 15:07:20
【问题描述】:

当您滚动时,我有一个侧边栏。现在我希望它在到达某个 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;
}

HTML:

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

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

 </div>

JS:

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

【问题讨论】:

  • 碰到这个问题

标签: twitter-bootstrap scroll affix


【解决方案1】:

你可以使用底部偏移

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

并添加以下css

.affix-bottom { 
    position: absolute; 
}

【讨论】:

    猜你喜欢
    • 2014-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-11
    • 1970-01-01
    • 2013-08-25
    • 2017-06-18
    • 2012-05-11
    相关资源
    最近更新 更多