我正在尝试使用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
原文地址:https://www.jb51.cc/bootstrap/233902.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。