bootstrap网站不会滚动

时间:2016-06-24 23:15:01

标签: html css twitter-bootstrap scroll

我正在codepen.io上创建一个投资组合网页。到目前为止,一切都很顺利,因为我的页面只是停止滚动,我无法找到导致页面停止滚动的代码片段的解决方案/标识。 这是我的代码:



body {
  padding-top: 50px;
}
.intro-text {
  font-size: 30px;
}
#About {
  height: 500px;
}
#Portfolio {
  height: 500px;
}
#Social {
  height: 500px;
}

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />

<body data-spy="scroll" data-target=".navbar">
  <nav class="navbar navbar-default navbar-fixed-top">
    <div class="container">

      <a href="#" class="navbar-brand">Ray Fitzgerald</a>

      <button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse">button
      </button>

      <div class="collapse navbar-collapse navHeaderCollapse">
        <ul class="nav navbar-nav">
          <li><a href="#About">About</a>
          </li>
          <li><a href="#Portfolio">Portfollio</a>
          </li>
          <li><a href="#Social">Social</a>
          </li>
        </ul>
      </div>

    </div>

    <!-- Main Body & Text Items -->
    <div class="container">
      <div class="jumbotron">
        <div class="intro-text" id="About">
          My name is Ray Fitzgerald and I am a young Programmer and Web Developer
        </div>
        <div class="intro-text" id="Portfolio">
          Portfolio
        </div>
        <div class="intro-text" id="Social">
          Social
        </div>

      </div>
    </div>
  </nav>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

<!-- Main Body & Text Items --> navbar-fixed-top元素中取出<nav>

请参阅小提琴http://jsfiddle.net/85qLh41a/2/

<body data-spy="scroll" data-target=".navbar">
  <nav class="navbar navbar-default navbar-fixed-top">
    <div class="container">

      <a href="#" class="navbar-brand">Ray Fitzgerald</a>

      <button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse">button
      </button>

      <div class="collapse navbar-collapse navHeaderCollapse">
        <ul class="nav navbar-nav">
          <li><a href="#About">About</a>
          </li>
          <li><a href="#Portfolio">Portfollio</a>
          </li>
          <li><a href="#Social">Social</a>
          </li>
        </ul>
      </div>

    </div>
  </nav>
   <!-- Main Body & Text Items -->
    <div class="container">
      <div class="jumbotron">
        <div class="intro-text" id="About">
          My name is Ray Fitzgerald and I am a young Programmer and Web Developer
        </div>
        <div class="intro-text" id="Portfolio">
          Portfolio
        </div>
        <div class="intro-text" id="Social">
          Social
        </div>

      </div>
    </div>
</body>