twitter-bootstrap – 使用Twitter Bootstrap Affix溢出侧边栏

我正在尝试使用twitter bootstrap的affix插件,但我无法弄清楚如何在父容器中约束它,我创建了以下示例来显示我的问题:

问题演示:http://www.codeply.com/go/DvcRXkeFZa

<div class="container">
    <div class="row">
        <div class="col-md-3 column">
            <ul id="sidebar" class="well nav nav-stacked" data-spy="affix" data-offset-top="130">
                <li><a href="#software"><b>Software</b></a></li>
                <li><a href="#features">Features</a></li>
                <li><a href="#benefits">Benefits</a></li>
                <li><a href="#costs">Costs</a></li>
            </ul>
        </div>
        <div class="col-md-9 column">
            <h1>Blah,blah,blah</h1>
            <hr>
            <a class="anchor3" id="top" name="software"></a>
            <p>
             content here that scrolls...
            </p>
        </div>
    </div>
</div>

正如您所看到的那样,当它滚动时,它会溢出侧边栏,当它到达底部时也不会粘贴到页面底部.

解决方法

来自Bootstrap文档( http://getbootstrap.com/2.3.2/javascript.html#affix)..

Heads up! You must manage the position of a pinned element and the
behavior of its immediate parent. Position is controlled by affix,
affix-top,and affix-bottom. Remember to check for a potentially
collapsed parent when the affix kicks in as it’s removing content from
the normal flow of the page.

所以你需要一些CSS for affix来设置元素固定时的宽度.如:

#sidebar.affix {
    position: fixed;
    top: 0;
    width:225px;
  }

Bootply演示:http://bootply.com/73864

关于Bootstrap词缀的相关回答:
How to create a sticky left sidebar menu using bootstrap 3?
Twitter-bootstrap 3 affixed sidebar overlapping content when window resized and also footer

相关文章

Bootstrip HTML 查询搜索常用格式模版 &lt;form class=&...
如何在按钮上加红色数字 您可以使用Bootstrap的badge组件来在...
要让两个按钮左右排列,你可以使用 Bootstrap 的网格系统将它...
是的,可以将status设置为布尔类型,这样可以在前端使用复选...
前端工程师一般用的是Bootstrap的框架而不是样式,样式一般自...
起步导入:<linkrel="stylesheet"href="b...