移动引导导航栏按钮不会折叠

时间:2017-08-21 19:12:29

标签: html css twitter-bootstrap

我知道这已被发布了很多次,但我仍然无法找到解决方案。我试过在移动设备上观看它并缩小浏览器但是所有的导航折叠按钮都没有崩溃。"我按照其他帖子提供的指导,但没有一个有效。我已将data-target设置为正确的ID,并且我已获取所有脚本。

我的代码:



nav ul li{
    width:117px;
}
nav{
    box-shadow: 15px 0px 45px #1f2021;
}
.navbar-fixed-top{
    position:absolute!important;
}

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, 
    minimum-scale=1, maximum-scale=1" />

  <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
  <title>Title</title>

  <!-- Bootstrap -->
  <link href="css/blog.css" rel="stylesheet" type="text/css">
  <link href="css/bootstrap.min.css" rel="stylesheet">
  <link href="css/starter-template.css" rel="stylesheet" type="text/css">
  <link rel="stylesheet" media="only screen and (min-width:1261px)" href="css/custom.css">
  <link rel="stylesheet" media="only screen and (min-width:781px) and 
    (max-width:1260px)" href="css/tablet.css">
  <link rel="stylesheet" media="only screen and (max-width:780px)" href="css/mobile.css">
  <script src="jquery-3.2.1.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">
  </script>
  <script>
    window.jQuery || document.write('<script 
        src = "../../assets/js/vendor/jquery.min.js" > < \/script>')
  </script>
  <script src="../../dist/js/bootstrap.min.js"></script>
  <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
  <link rel="manifest" href="manifest.json">
  <meta name="msapplication-TileColor" content="#ffffff">
  <meta name="msapplication-TileImage" content="ms-icon-144x144.png">
  <meta name="theme-color" content="#ffffff">
</head>
<body>
  <div id="main-content">
    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="logoSpace">
        <center> <img id="logo" src="img/logo.png"><br /></center>
      </div>
      <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>
        </div>

        <div id="navbar" class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
            <li><a href="index.html">Home <span class="glyphicon glyphicon-home" 
    aria-hidden="true"></span></a></li>
            <li><a href="about.html">About  <span class="glyphicon 
    glyphicon-plus" aria-hidden="true"></span></a></li>
            <li class="active"><a href="roster.html">Roster  <span 
    class="glyphicon glyphicon-user"></span></a></li>
            <li><a href="history.html">History  <span class="glyphicon 
    glyphicon-list-alt"></span></a></li>
            <li style="width:130px;float:left;"><a href="schedule.html">Schedule <span class="glyphicon glyphicon-list">
    </span></a></li>
            <li><a href="photos.html">Photos  <span class="glyphicon 
    glyphicon-camera" aria-hidden="true"></span></a></li>
            <li><a href="videos.html">Videos  <span class="glyphicon 
    glyphicon-film"></span></a></li>
            <li><a href="coaches.html">Coaches  <span class="glyphicon 
    glyphicon-book"></span></a></li>
            <li><a href="contact.html">Contact  <span class="glyphicon 
    glyphicon-send"></a></li>
          </ul>
        </div>
        <!--/.nav-collapse -->
      </div>
    </nav>
</body>
</html>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

为什么你有这么多样式表?似乎引导样式表没有呈现。

答案 1 :(得分:0)

你有一些错位的标签。喜欢丢失</div></span>。这个有效。

div#navbar.navbar-collapse.collapse.in {
    max-height:600px
}
nav{
    box-shadow: 15px 0px 45px #1f2021;
}
<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.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<!-- Fixed navbar -->
<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="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li><a href="index.html">Home <span class="glyphicon glyphicon-home" 
aria-hidden="true"></span></a></li>
        <li><a href="about.html">About  <span class="glyphicon 
glyphicon-plus" aria-hidden="true"></span></a></li>
        <li class="active"><a href="roster.html">Roster  <span 
class="glyphicon glyphicon-user"></span></a></li>
        <li><a href="history.html">History  <span class="glyphicon 
glyphicon-list-alt"></span></a></li>
        <li><a href="schedule.html">Schedule <span class="glyphicon glyphicon-list">
</span></a></li>
        <li><a href="photos.html">Photos  <span class="glyphicon 
glyphicon-camera" aria-hidden="true"></span></a></li>
        <li><a href="videos.html">Videos  <span class="glyphicon 
glyphicon-film"></span></a></li>
        <li><a href="coaches.html">Coaches  <span class="glyphicon 
glyphicon-book"></span></a></li>
        <li><a href="contact.html">Contact  <span class="glyphicon 
glyphicon-send"></span></a></li>
      </ul>

    </div>
    <!--/.nav-collapse -->
  </div>
</nav>

<div class="container">

  <div class="jumbotron">
    <h1>Navbar example</h1>
    <p>This example is a quick exercise to illustrate how the fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
  </div>
</div>

<!-- /container -->