Bootstrap导航栏未正确加载

时间:2017-12-31 18:46:06

标签: html css twitter-bootstrap

我是bootstrap的新手,我最近使用了他们的一个模板,一切正常,但我的导航栏没有正确加载,它应该是这样的: What i Should be getting

但它在chrome和firefox中看起来都是这样的: What I get

这是我的html(只有导航部分)



<nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
          <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">Project name</a>
          </div>
          <div id="navbar" class="collapse navbar-collapse">
            <ul class="nav navbar-nav">
              <li class="active"><a href="#">Home</a></li>
              <li><a href="#about">About</a></li>
              <li><a href="#contact">Contact</a></li>
            </ul>
          </div><!--/.nav-collapse -->
        </div>
      </nav>
&#13;
&#13;
&#13; 你能帮忙吗?

2 个答案:

答案 0 :(得分:0)

我认为你的CSS没有正确加载。尝试将此添加到您的网页&lt; head&gt;来自http://getbootstrap.com/docs/3.3/getting-started/#download

&#13;
&#13;
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
&#13;
&#13;
&#13;

它只是Bootstrap的副本。如果可行,那么您知道问题出在您的本地副本上(如果您正在使用一个或您的CDN),如果它没有,那么问题出在其他地方。

编辑:我应该编辑说我已经测试了你在另一个网站上提供的代码,它似乎工作正常。

答案 1 :(得分:0)

在jsfiddle上正常工作:

https://jsfiddle.net/ajrvrtz6/

我用过: butstrap v3.3

<!-- Latest compiled and minified CSS --> 
<link rel="stylesheet" href="maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/…; integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg‌​4Va+PmSTsz/K68vbdEjh‌​4u" crossorigin="anonymous"> 
<!-- Latest compiled and minified JavaScript --> 
<script src="maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/…; integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mC‌​WNIpG9mGCD8wGNIcPD7T‌​xa" crossorigin="anonymous"></script>