微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

twitter-bootstrap – 如何使用Bootstrap滚动间谍?

我不能得到滚动间谍工作正常与垂直导航。下面你可以找到我使用的代码。由于某种原因,只有“Two”被激活。

任何人都有什么错误的想法?

<html lang="en">
<head>
    <Meta charset="utf-8">
    <title>Twitter Bootstrap Scroll Spy Playground</title>
    <link href="bootstrap/css/bootstrap.css" rel="stylesheet">
  </head>
  <body>
    <div class="container">
      <div class="row">
        <div class="span3">
            <ul class="navbar nav nav-list affix">
              <li class="active"><a href="#one">One</a></li>
              <li><a href="#two">Two</a></li>
            </ul>
        </div>
        <div class="span1" data-spy="scroll">
            <section id="one">
            <h1>One</h1>
            <h2>Ad leggings keytar,brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. </h2>
            </section>
            <section id="two">
            <h1>Two</h1>
           <h2>Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Nihil tattooed accusamus,cred irony biodiesel keffiyeh artisan ullamco consequat.</h2>
            </section>   
        </div>
      </div>
    </div>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>

解决方法

在为自己排序这个问题,我发现被监视的元素需要有一个滚动条。

看看这个小提琴:http://jsfiddle.net/adamp/qgU6h/1/

你可以直接侦听body元素($(‘body’)。scrollspy())或者给你的内容一个明确的高度,并强制它显示一个滚动条。

(如果你看Bootstrap documentation example,它是固定高度的技巧。)

原文地址:https://www.jb51.cc/bootstrap/234415.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐