Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        4年前关闭。
                                                                                            
                
        
关于navbar折叠功能的问题,关于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>

最佳答案

您保留了data-toggle而不是classdiv。如下更改:

<div class="collapse navbar-collapse">
    <form class="navbar-form navbar-right" method="post">
    .....
    </form>
</div>

08-25 09:40
查看更多