我有一个导航栏。在里面我有一个搜索表单和一个额外的按钮。问题是按钮未与导航栏中的其他元素对齐:
这是我的代码。任何人都明白为什么他们不应该对齐?
<html>
<head>
<title>Bootstrap 3 </title>
<link href ="css/bootstrap.css" rel = "stylesheet">
<link href ="css/bootstrap.min.css" rel = "stylesheet">
<link href ="css/bootstrap-theme.min.css" rel = "stylesheet">
<link href ="css/styles.css" rel = "stylesheet">
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<!-- box -->
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
<!-- Single button -->
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
Action <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</div>
</div>
</nav>
</body>
</html>
答案 0 :(得分:1)
您需要将类navbar-btn添加到按钮:
<button type="button" class="navbar-btn btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
Action <span class="caret"></span>
</button>