因此,当我慢慢学习Bootstrap时,我遇到了一个新问题,我不太确定如何解决。我的页面顶部有一个粘性导航栏,如下所示:
现在您可以立即看到问题。右侧的登录表单与导航栏的其余部分不一致。我不完全确定我在这里缺少的是因为尝试添加“内联”(正如我见过其他人所做的那样)并没有真正改变任何东西。是因为我在使用表单时应该以不同的方式构建它吗?
我也可以很快看到我用来写“登录”的文字与着色时灰色阴影方面的其他菜单样式不匹配。
<div class="sticky-header-navbar-container">
<div class="well">
<div class="navbar navbar-default navbar-fixed-top" id="navbar">
<ul class="nav navbar-nav">
<li>
<a href="#">Home</a>
</li>
<li>
<a href="#">About</a>
</li>
<li>
<a href="#">Contact</a>
</li>
<li>
<form class="navbar-form" role="search">
<div class="input-group" style="width: 100%">
<input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term-header">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span></button>
</div>
</div>
</form>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#">Register</a>
</li>
<li>
<form class="form-signin">
<p>Login</p>
<label for="inputEmail" class="sr-only">Email address</label>
<input type="email" id="inputEmail" class="form-control" placeholder="Email Address" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<div class="checkbox">
<label>
<input type="checkbox" value="remember-me"> Remember Me
</label>
</div>
</form>
<div class="btn-group" role="button">
<button type="button" class="btn btn-success btn-bg" id="signin-btn">Sign In</button>
</div>
</li>
</ul>
</div>
</div>
</div>
答案 0 :(得分:2)
您需要进行一些更改:
<p>Login</p>
更改为<span>Login</span>
(跨度是内联元素)<button ...>Sign In</button>
并删除它所在的div navbar-form
添加到您登录表单的class
属性中。这是最终的代码:
<div class="sticky-header-navbar-container">
<div class="well">
<div class="navbar navbar-default navbar-fixed-top" id="navbar">
<ul class="nav navbar-nav">
<li>
<a href="#">Home</a>
</li>
<li>
<a href="#">About</a>
</li>
<li>
<a href="#">Contact</a>
</li>
<li>
<form class="navbar-form" role="search">
<div class="input-group" style="width: 100%">
<input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term-header">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span></button>
</div>
</div>
</form>
</li>
</ul>
<ul class="nav navbar-nav navbar-right line-inline">
<li>
<a href="#">Register</a>
</li>
<li>
<!-- Changes I made start here -->
<form class="form-signin navbar-form">
<span>Login</span>
<label for="inputEmail" class="sr-only">Email address</label>
<input type="email" id="inputEmail" class="form-control" placeholder="Email Address" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<div class="checkbox">
<label>
<input type="checkbox" value="remember-me"> Remember Me
</label>
</div>
<button type="button" class="btn btn-success btn-bg" id="signin-btn">Sign In</button>
</form>
</li>
</ul>
</div>
</div>
</div>
这是我能够制作的:
答案 1 :(得分:0)
表格
在<div class="col-md-12"><div>
或6