调整窗口大小时,Navbar不会折叠

时间:2015-08-20 17:12:17

标签: javascript jquery html css twitter-bootstrap

Stack Overflow上几乎没有关于导航栏折叠功能问题的问题。我确实看过它们,但没有一个能解决我遇到的问题。

我的导航栏中有一个登录表单,当我调整窗口大小时,登录保持“打开”状态,而不是像它应该的那样折叠。当我单击菜单按钮时没有任何反应。我不确定这是“数据切换”或“导航栏崩溃”的问题,还是两者兼而有之。

<!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">
<title>Journal</title>
<!-- Bootstrap -->
<!--
<link href="css/bootstrap.min.css" rel="stylesheet">
-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
</head>
<body data-spy="scroll" data-target=".navbar-collapse">
  <div class="navbar navbar-default navbar-fixed-top">
    <div class="container">
      <div class="navbar-header">
        <button class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand">Journal</a>
      </div>
    <div data-toggle="collapse navbar-collapse">
      <form class="navbar-form navbar-right" method="post"> 
        <div class="form-group">
          <input type="email" name="loginemail" placeholder="Email" class="form-control" value="<?php echo addslashes($_POST['loginemail']); ?>" />                                                        
        </div>
        <div class="form-group">
          <input type="password" name="loginpassword" placeholder="Password" class="form-control" value="<?php echo addslashes($_POST['loginpassword']); ?>" />                                                                 
        </div>
          <input type="submit" name= "submit" class="btn btn-success" value="Log In">
      </form>
    </div>
  </div>    
</div>
<!--
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

  

1 个答案:

答案 0 :(得分:1)

您为div保留了数据切换而不是类。将其更改如下: &lt; div class =“collapse navbar-collapse”&gt;     &lt; form class =“navbar-form navbar-right”method =“post”&gt;     .....     &LT; /形式&GT; &LT; / DIV&GT;