-->

Issue with Bootstraps Navbar, doesn't open [du

2019-09-12 04:43发布

问题:

This question already has an answer here:

  • bootsrap nav-bar collapsable cannot make it work 1 answer

Basicly my problem is, I can't open the navbar if it gets collapsed (small window) and can't spot the misstake.

What i want is this http://getbootstrap.com/examples/navbar-fixed-top/

    <!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">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../../favicon.ico">

    <title>Fixed Top Navbar Example for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link href="../../dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="../../assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="navbar-fixed-top.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="../../assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>

    <!-- Fixed navbar -->
    <nav class="navbar navbar-default 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 class="active"><a href="#">Home</a></li>
            <li><a href="#about">About</a></li>
            <li><a href="#contact">Contact</a></li>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="#">Action</a></li>
                <li><a href="#">Another action</a></li>
                <li><a href="#">Something else here</a></li>
                <li role="separator" class="divider"></li>
                <li class="dropdown-header">Nav header</li>
                <li><a href="#">Separated link</a></li>
                <li><a href="#">One more separated link</a></li>
              </ul>
            </li>
          </ul>
          <ul class="nav navbar-nav navbar-right">
            <li><a href="../navbar/">Default</a></li>
            <li><a href="../navbar-static-top/">Static top</a></li>
            <li class="active"><a href="./">Fixed top <span class="sr-only">(current)</span></a></li>
          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </nav>

    <div class="container">

      <!-- Main component for a primary marketing message or call to action -->
      <div class="jumbotron">
        <h1>Navbar example</h1>
        <p>This example is a quick exercise to illustrate how the default, static and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
        <p>To see the difference between static and fixed top navbars, just scroll.</p>
        <p>
          <a class="btn btn-lg btn-primary" href="../../components/#navbar" role="button">View navbar docs &raquo;</a>
        </p>
      </div>

    </div> <!-- /container -->


    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <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>
  </body>
</html>

But no matter what i try it doesn't work on my Page http://myschooldesk.de/index.php?id=5#

    <!DOCTYPE html>
<html lang="en">
<head>

<meta charset="utf-8">
<!-- 
    This website is powered by TYPO3 - inspiring people to share!
    TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
    TYPO3 is copyright 1998-2016 of Kasper Skaarhoj. Extensions are copyright of their respective owners.
    Information and contribution at http://typo3.org/
-->



<title>TITE: Home</title>
<meta name="generator" content="TYPO3 CMS">


<link rel="stylesheet" type="text/css" href="typo3temp/stylesheet_a490dd7cbb.css?1483100214" media="all">
<link rel="stylesheet" type="text/css" href="typo3conf/ext/myschooldesk_dis/Resources/Public/Bootstrap/css/bootstrap.min.css?1483097509" media="all">
<link rel="stylesheet" type="text/css" href="typo3conf/ext/myschooldesk_dis/Resources/Public/Bootstrap/css/bootstrap-theme.min.css?1483097509" media="all">
<link rel="stylesheet" type="text/css" href="typo3conf/ext/myschooldesk_dis/Resources/Public/Css/basicLayout.css?1483313684" media="all">


<script src="uploads/tx_t3jquery/jquery-1.8.x-1.9.x.js?1483135375" type="text/javascript"></script>
<script src="typo3conf/ext/myschooldesk_dis/Resources/Public/Bootstrap/js/bootstrap.min.js?1483097509" type="text/javascript"></script>



</head>
<body>



    <!-- Fixed navbar -->
    <nav class="navbar navbar-default 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" aria-expanded="false" style="height: 0.8px;">
          <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>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="#">Action</a></li>
                <li><a href="#">Another action</a></li>
                <li><a href="#">Something else here</a></li>
                <li role="separator" class="divider"></li>
                <li class="dropdown-header">Nav header</li>
                <li><a href="#">Separated link</a></li>
                <li><a href="#">One more separated link</a></li>
              </ul>
            </li>
          </ul>
          <ul class="nav navbar-nav navbar-right">
            <li><a href="../navbar/">Default</a></li>
            <li><a href="../navbar-static-top/">Static top</a></li>
            <li class="active"><a href="./">Fixed top <span class="sr-only">(current)</span></a></li>
          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </nav>

    <div class="container">

      <!-- Main component for a primary marketing message or call to action -->
      <div class="jumbotron">
        <h1>Navbar example</h1>
        <p>This example is a quick exercise to illustrate how the default, static and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
        <p>To see the difference between static and fixed top navbars, just scroll.</p>
        <p>
          <a class="btn btn-lg btn-primary" href="../../components/#navbar" role="button">View navbar docs »</a>
        </p>
      </div>

    </div> <!-- /container -->


   <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>




</body>
</html>

Actualy i have the same problem with the dropdown menue and that might be related. On the Serverside I use Typo 3 6.2 what limits me a bit in just copying everithing, as far as i know. Can it be a version problem or did i overlocked something.

So far I've ckecked:

  • All imports are the same or doesn't matter in this context
  • I tryed diffrent browsers
  • Restart
  • Clearing Cache both mine and typo 3's

I am new to Stack Overflow and tryed my best if i still missed anything feel free to ask.

Thanks everyone. :)

回答1:

You have a javascript error on a page:

Uncaught Error: Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4

To fix it you should use jQuery version 1.9.1 or higher. Or just use the CDN:

<script src="https://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="./TITE_ Home_files/bootstrap.min.js.download" type="text/javascript"></script>


回答2:

You need jQuery in order to use Bootstrap Javascript. Include this line of code before you load in your Bootstrap:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>

Your HTML <head> section should now look like this:

<head>

<meta charset="utf-8">
<!-- 
    This website is powered by TYPO3 - inspiring people to share!
    TYPO3 is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.
    TYPO3 is copyright 1998-2016 of Kasper Skaarhoj. Extensions are copyright of their respective owners.
    Information and contribution at http://typo3.org/
-->



<title>TITE: Home</title>
<meta name="generator" content="TYPO3 CMS">


<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <!-- This was changed -->
<link rel="stylesheet" type="text/css" href="typo3temp/stylesheet_a490dd7cbb.css?1483100214" media="all">
<link rel="stylesheet" type="text/css" href="typo3conf/ext/myschooldesk_dis/Resources/Public/Bootstrap/css/bootstrap.min.css?1483097509" media="all">
<link rel="stylesheet" type="text/css" href="typo3conf/ext/myschooldesk_dis/Resources/Public/Bootstrap/css/bootstrap-theme.min.css?1483097509" media="all">
<link rel="stylesheet" type="text/css" href="typo3conf/ext/myschooldesk_dis/Resources/Public/Css/basicLayout.css?1483313684" media="all">


<script src="uploads/tx_t3jquery/jquery-1.8.x-1.9.x.js?1483135375" type="text/javascript"></script>
<script src="typo3conf/ext/myschooldesk_dis/Resources/Public/Bootstrap/js/bootstrap.min.js?1483097509" type="text/javascript"></script>



</head>