当我向下滚动时,Twitter引导程序附加的侧边栏会崩溃

And*_*son 5 jquery twitter-bootstrap

我正在尝试创建一个类似于Twitter bootstrap文档中的侧边栏:http://twitter.github.com/bootstrap/getting-started.html

我已经有了词缀工作,但除非你滚过数据偏移,否则栏会崩溃,因为它没有.

HTML

<div class="span3">
          <ul data-spy="affix" data-offset-top="255" class="nav nav-tabs nav-stacked docs-sidebar" id="navbar">
            <li><a href="#grid">Grid system <i class="icon-chevron-right pull-right"></i></a></li>
            <li><a href="#fluidGridSystem">Fluid grid system <i class="icon-chevron-right pull-right"></i></a></li>
            <li><a href="#layouts">Layouts <i class="icon-chevron-right pull-right"></i></a></li>
            <li><a href="#responsive">Responsive design <i class="icon-chevron-right pull-right"></i></a></li>
          </ul>
          <p></p>
       </div>
Run Code Online (Sandbox Code Playgroud)

减

    // For Affix plugin
.affix {
  position: fixed;
  top: (@navbarHeight * 1.8) + @navbarPadding + 25px;
}

.docs-sidebar {
    width: (@gridColumnWidth * 4);
}
Run Code Online (Sandbox Code Playgroud)

这使得侧边栏成为固定的span4宽度,但不会使其响应.我如何确保它具有响应性?

Joh*_*yck 0

我也在努力找出最好的方法来做到这一点。这就是我所做的。也许不是最好的解决方案,但它确实有效。

我有一个两列布局,我想在其中添加左侧 .affix。我将列从行中拉出以固定,并将其放在原来的行上方。我通过添加 .offset3 将剩余的列移回原位。我将 .affix 放在 div 列上而不是 ul 上。然后我将固定列包裹在一个 div 中,CSS 为position:absolute; (位于 .row div 内部和 .col3 div 外部)这会将两个 .row div 重叠,其中一个固定,另一个滚动。