Bootstrap多个下拉按钮无法正常显示

时间:2017-12-24 06:57:22

标签: html css twitter-bootstrap

我在互联网上搜索过,甚至在这个网站上搜索答案但没有运气。我遇到的问题是两个下拉按钮登录和注册时显示两个下拉菜单单击时我使用btn-group类来修复此问题然后出现问题它不能在较小的移动设备上正常显示屏幕将其更改为btn类只是稍微修复它的问题是选项是水平显示而不是堆叠看起来很糟糕。我也尝试过数据目标,但这不起作用或者任何帮助都会受到赞赏。这是我的html和css代码示例。

代码



.navbar {
  background-color: #00CED1;
  border: none;
}

.navbar-default .navbar-brand {
  color: white;
  font-family: Tahoma;
  font-size: 20px;
  font-style: italic;
}

.navbar-left {
  width: 70%;
  margin-left: -15px;
}

#navForm {
  border: none;
}

#loginbtn {
  margin-right: 16px;
  background: none;
  color: white;
  border: 2px solid white;
}

#searchbtn {
  margin-left: -13px;
  background-color: #00b3b3;
  color: white;
  border-color: #00b3b3;
}

#submitbtn {
  width: 100%;
}

#burgerbtn:hover {
  background-color: #1673b1;
}

#searchbtn:hover {
  background-color: #1673b1;
  border-color: #1673b1;
}

#search {
  width: 100%;
  background-color: #00b3b3;
  border: none;
  color: white;
}

#password,
#username {
  margin-top: 15px;
}

b,
strong {
  color: #1673b1;
}

#form {
  border: none;
}

#navdiv {
  border: none;
}

#form2 input::placeholder {
  color: white;
}

#form input::placeholder {
  color: white;
}

.navbar-default .navbar-toggle .icon-bar {
  background-color: white;
}

.dropdown-menu {
  padding-left: 15px;
  padding-right: 15px;
}

@media screen and (max-width: 720px) {
  b,
  strong {
    position: absolute;
    top: 0.5%;
    left: 35%;
  }
  #navdiv {
    width: 80%;
  }
  .navbar-toggle {
    border: none;
  }
  #navdiv {
    width: 165%;
  }
  .navbar-left {
    width: 100%;
  }
  #loginbtn {
    margin-left: 5%;
  }
}

#navdiv1 {
  border: 1px solid black;
}

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

<head>
  <title>LearnLyte Connect Share Learn</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
  <link rel="stylesheet" type="text/css" href="css/app-bootstrap.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>

<body>
  <nav class="navbar navbar-default navbar-fixed-top">
    <div class="container-fluid">
      <div class="navbar-header">
        <a class="navbar-brand" href="#"><strong><font color="white">LearnLyte</font></strong></a>
        <button id="burgerbtn" type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navForm">
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
      </div>
      <div id="navdiv" class="navbar-left navbar-form">
        <form id="form">
          <div class="form-group col-xs-6">
            <input id="search" type="text" class="form-control" placeholder="Search Here...">
          </div>
          <button type="submit" id="searchbtn" class="btn btn-default">Search</button>
        </form>
      </div>
      <div class="navbar-right form-inline">
        <div class=" collapse navbar-collapse navbar-form" id="navForm">
          <!--<div>-->
          <button id="signupbtn" type="button" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Sign Up</button>
          <div class="dropdown-menu">
            <div class="text-center">
              <h4><b> Sign Up</b></h4>
            </div><br>
            <form autocomplete="off">
              <div class="form-group">
                <label for="firstname">Firstname</label>
                <input type="text" id="firstname" tabindex="1" class="form-control" placeholder="Firstname">
              </div>
              <div class="form-group">
                <label for="lastname">Lastname</label>
                <input type="text" id="lastname" tabindex="2" class="form-control" placeholder="Lastname">
              </div>
              <div class="form-group">
                <label for="username">Username</label>
                <input type="text" tabindex="3" class="form-control" placeholder="Username">
              </div>
              <div class="form-group">
                <label for="email">Email</label>
                <input type="email" tabindex="4" class="form-control" placeholder="Email">
              </div>
            </form>
          </div>
          <!--</div>-->
          <!--<div>-->
          <button id="loginbtn" type="button" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Sign In</button>
          <div class="dropdown-menu">
            <div class="text-center">
              <h4><b> Sign In</b></h4>
            </div><br>
            <form autocomplete="off">
              <div class="form group">
                <label for="username">Username</label>
                <input type="text" id="username" tabindex="1" class="form-control" placeholder="Username" autocomplete="off">
              </div>
              <div class="form-group">
                <label for="password">Password</label>
                <input type="password" id="password" tabindex="2" class="form-control" placeholder="Password" autocomplete="off">
              </div>
              <br>
              <div class="form-group">
                <div class="text-center">
                  <a href="#" class="forgot-password">Forgot password?</a>
                </div>
              </div>
              <br><br>
              <div>
                <button id="submitbtn" type="submit" class="btn btn-primary btn-block">Sign In</button>
              </div>
            </form>
          </div>
          <!--</div>-->
        </div>
      </div>
    </div>
  </nav>
  <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <script type="text/javascript" src="js/bootstrap.min.js"></script>
  <script type="text/javascript" src="js/bootstrap.js"></script>
</body>

</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

试试这个

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

<head>
  <title>LearnLyte Connect Share Learn</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>

<body>
  <nav class="navbar navbar-default navbar-fixed-top">
    <div class="container-fluid">
      <div class="navbar-header">
        <a class="navbar-brand" href="#"><strong><font color="white">LearnLyte</font></strong></a>
        <button id="burgerbtn" type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navForm">
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
      </div>
      <div id="navdiv" class="navbar-left navbar-form">
        <form id="form">
          <div class="input-group">
            <input id="search" type="text" class="form-control" placeholder="Search Here...">
            <span class="input-group-btn">
							<button type ="submit" id="searchbtn"class="btn btn-default">Search</button>
						</span>
          </div>
        </form>
      </div>
      <div class="navbar-right form-inline">
        <div class=" collapse navbar-collapse navbar-form" id="navForm">
          <!--<div>-->
          <button id="signupbtn" type="button" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Sign Up</button>
          <div class="dropdown-menu">
            <div class="text-center">
              <h4><b> Sign Up</b></h4>
            </div>
            <br>
            <form autocomplete="off">
              <div class="form-group">
                <label for="firstname">Firstname</label>
                <input type="text" id="firstname" tabindex="1" class="form-control" placeholder="Firstname">
              </div>
              <div class="form-group">
                <label for="lastname">Lastname</label>
                <input type="text" id="lastname" tabindex="2" class="form-control" placeholder="Lastname">
              </div>
              <div class="form-group">
                <label for="username">Username</label>
                <input type="text" tabindex="3" class="form-control" placeholder="Username">
              </div>
              <div class="form-group">
                <label for="email">Email</label>
                <input type="email" tabindex="4" class="form-control" placeholder="Email">
              </div>
            </form>
          </div>
          <!--</div>-->
          <!--<div>-->
          <button id="loginbtn" type="button" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Sign In</button>
          <div class="dropdown-menu">
            <div class="text-center">
              <h4><b> Sign In</b></h4>
            </div>
            <br>
            <form autocomplete="off">
              <div class="form group">
                <label for="username">Username</label>
                <input type="text" id="username" tabindex="1" class="form-control" placeholder="Username" autocomplete="off">
              </div>
              <div class="form-group">
                <label for="password">Password</label>
                <input type="password" id="password" tabindex="2" class="form-control" placeholder="Password" autocomplete="off">
              </div>
              <br>
              <div class="form-group">
                <div class="text-center">
                  <a href="#" class="forgot-password">Forgot password?</a>
                </div>
              </div>
              <br>
              <br>
              <div>
                <button id="submitbtn" type="submit" class="btn btn-primary btn-block">Sign In</button>
              </div>
            </form>
          </div>
          <!--</div>-->
        </div>
      </div>
    </div>
  </nav>
  <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>

</html>