1
這裏是我想實現的東西的例子:引導下拉菜單,菜單項添加文本字段點擊
如何創建一個在單擊下拉菜單文本形式。下面的例子中,如何將登錄名(目前在導航欄中)移動到下拉菜單中,並仍然保留它在點擊時的功能(但現在在下拉菜單中顯示文本框和登錄按鈕)?
這裏是我想實現的東西的例子:引導下拉菜單,菜單項添加文本字段點擊
如何創建一個在單擊下拉菜單文本形式。下面的例子中,如何將登錄名(目前在導航欄中)移動到下拉菜單中,並仍然保留它在點擊時的功能(但現在在下拉菜單中顯示文本框和登錄按鈕)?
您最終可以像添加任何其他元素一樣添加表單。
.navbar .dropdown-menu {
width: 300px;
padding: 10px;
}
.navbar .dropdown-menu {
border-radius: 0;
box-shadow: none;
}
.navbar .dropdown-menu form .form-group .form-control,
.navbar .dropdown-menu form .form-group label,
.navbar .dropdown-menu form .form-group .btn-primary {
margin: 5px 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <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="#">Brand</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Link <span class="sr-only">(current)</span></a>
</li>
<li><a href="#">Link</a>
</li>
<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li>
<form action="#">
<div class="form-group">
<label for="username">Username</label>
<input class="form-control" type="text" name="username" />
<label for="password">Password</label>
<input class="form-control" type="password" name="password" />
<input class="btn btn-default" type="submit" name="submit" value="Sign In" />
</div>
</form>
</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>