Bootstrap 3折叠按钮不显示内容

时间:2013-12-08 23:44:05

标签: twitter-bootstrap twitter-bootstrap-3 navbar

通常我会在没有发帖的情况下找到问题的答案,但今天却没有。

我正在建立一个带有bootstrap 3和来自www.bootswatch.com的mod的网站,我的导航栏没问题,显示折叠按钮但是一旦你点击它就没有显示菜单。我是新手,所以我可能会犯一些愚蠢的错误。这是代码(我放置了所有代码,因为它可能缺少一些.js文件(?)):

目:

<head>
<meta charset="utf-8" />
<title>Escola Artes e Letras</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="css/bootstrap.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/custom.css" rel="stylesheet">
<link href="css/layout.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>

导航栏:

<nav class="navbar navbar-default" role="navigation">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
        </div>
        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav navbar-left">
                <li>a escola</li>
                <li class="mleft40">educação</li>
                <li class="mleft40">cardápio</li>
                <li class="mleft40">calendário</li>
                <li class="mleft40">instalações e segurança</li>
                <li class="mleft40">fotos</li>
                <li class="mleft40">contato</li>
            </ul>
        </div> <!-- /.navbar-collapse -->
</nav>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://code.jquery.com/jquery.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

除非您运行自定义构建的Bootstrap或有其他紧迫的理由来提供本地文件,否则最佳做法是使用CDN来实现Bootstrap依赖性。您可以在此处找到它:http://www.bootstrapcdn.com

像普通文件一样将它们添加到你的参考:

<link href="//netdna.bootstrapcdn.com/bootstrap/x.x.x/css/bootstrap.min.css" rel="stylesheet">
<script src="//netdna.bootstrapcdn.com/bootstrap/x.x.x/js/bootstrap.min.js"></script>

这不仅可以确保您使用正确的文件 - 它还可以进一步减轻服务器的负担,因为文件将从其他地方传送到您的客户端。