我在导航栏中做了一些修改,但是现在切换按钮在单击时没有响应。下面是我的代码。我哪里错了??
码:
<body> <div class="navbar-wrapper"> <div class="container"> <div class="navbar navbar-default navbar-static-top" role="navigation"> <div class="container"> <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> </button> <a class="navbar-brand" href="./index.html">ossoc</a> </div> <div class="collapse navbar-collapse"> <ul class="nav navbar-nav navbar-right"> <button id="loginbutton" type="button" class="btn btn-primary narbar-btn"><i class="glyphicon glyphicon-log-in"></i>Login</button> <button type="button" class="btn btn-success navbar-btn"><i class="glyphicon glyphicon-link"></i><a href="./register.jsp">Create account</a></button> </ul> </div> </div> </div> </div> </div>
您需要更改此标记
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar collapse">
改变
data-target=".navbar collapse"
至
data-target=".navbar-collapse"
原因:的值data-target是关联的nav div的任何类名。在这种情况下
data-target
<div class="collapse navbar-collapse"> <-- Look at here <ul class="nav navbar-nav navbar-right"> ..... </div>