为什么导航栏下的折叠选项不能在bootstrap3中工作?

时间:2017-02-12 10:55:58

标签: html html5 twitter-bootstrap-3

用于对导航栏中的选项列表进行分组的折叠选项无效。

请通过提供解决方案来检查HTML代码和帮助。 我希望它能够完全响应。

<!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 -->
        <title>TestRank</title>

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

    <body>
        <nav class="navbar navbar-default navbar-fixed-top">
            <div class="container-fluid">
            <div class="navbar-header">

                <button type="button" class="navbar-toggle" 
                        data-toogle="collapse" data-target="#mynavbar">
                    <!--<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="index.html"><img src= "Logo.png" style="width:120px; height:30px;" alt="TestRank" ></a>
            </div>
                <div class="navbar-collapse collapse" id="mynavbar">
                    <ul class="nav navbar-nav navbar-right">
                        <li><a href="index.html">Home</a></li>
                        <li><a href="About.html">About</a></li>
                        <li><a href="Features.html">Features</a></li>
                        <li><a href="Contact.html">Contact</a></li>
                    </ul>
                </div>
            </div>
        </nav>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
        <script src ="js/bootstrap.min.js"></script>
    </body>
</html>

1 个答案:

答案 0 :(得分:1)

您在<button type="button" class="navbar-toggle" data-toogle="collapse" data-target="#mynavbar" aria-expanded="false">处输入错误,其中data-toogle="collapse"错误,必须是data-toggle="collapse"

这是正确的代码:

<nav class="navbar navbar-default navbar-fixed-top">
    <div class="container-fluid">
    <div class="navbar-header">

        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#mynavbar"  aria-expanded="false">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>          
      <a class="navbar-brand" href="index.html"><img src= "Logo.png" style="width:120px; height:30px;" alt="TestRank" ></a>
    </div>

        <div class="collapse navbar-collapse" id="mynavbar">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="index.html">Home</a></li>
                <li><a href="About.html">About</a></li>
                <li><a href="Features.html">Features</a></li>
                <li><a href="Contact.html">Contact</a></li>
            </ul>
        </div>
    </div>
</nav>