使用 Twitter Bootstrap 的标题中的搜索框
我试图将搜索文本框放在标题的右侧,但我似乎不知道如何使用 Bootstrap 2.0.1 来做到这一点。 我正在尝试的代码是
<div class="page-header">
<h1 class="span2">
Parts
</h1>
<div class="span4">
<div class="control-group">
<div class="controls">
<div class="input-prepend">
<span class="add-on">
<i class="icon-search"></i>
</span>
<input type="search" class="span3" placeholder="Search" name="search" id="search"/>
</div>
</div>
</div>
</div>
</div>
但是搜索文本框没有被跨度和偏移量推到右侧,并且标题底部的行没有被推到标签的底部。有什么想法吗?
I am trying to place a search text box on the right hand side of the header and I can't seem to figure out how to do it using Bootstrap 2.0.1.
The code I am trying is
<div class="page-header">
<h1 class="span2">
Parts
</h1>
<div class="span4">
<div class="control-group">
<div class="controls">
<div class="input-prepend">
<span class="add-on">
<i class="icon-search"></i>
</span>
<input type="search" class="span3" placeholder="Search" name="search" id="search"/>
</div>
</div>
</div>
</div>
</div>
But it the search text box is not being pushed to the right with the spans and offsets and the line on the bottom of the header is not being pushed to the bottom of the tag. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将
float: right
添加到嵌套在.page-header
中的第一个 div 标签对我来说很有效。您还需要记住清除浮动,这就是标题底部的行没有被推到标签底部的原因。因此,添加以下 CSS 可以解决您的问题:
工作示例:http://jsfiddle.net/7zds9/
编辑
由于某种原因,正如 @PlTaylor 所指出的,输入字段在 Chrome 中换行。可以使用以下 CSS 来修复此问题:
工作示例:http://jsfiddle.net/7zds9/1 /
Adding
float: right
to the first div tag nested within.page-header
works for me. You also need to remember to clear your floats, this is the reason the line at bottom of the header is not being pushed to the bottom of the tag.So adding the following CSS would resolve your problem:
Working example: http://jsfiddle.net/7zds9/
Edit
For some reason, as pointed out by @PlTaylor, the input field wraps onto a new linein Chrome. This can be fixed using the following CSS:
Working example: http://jsfiddle.net/7zds9/1/
您可以使用:
http://jsfiddle.net/dXJb8/
或者您可以使用
position:固定;
设置搜索框的位置。http://jsfiddle.net/dXJb8/1/
You can use this:
http://jsfiddle.net/dXJb8/
Or you can use
position: fixed;
to set the location of your search box.http://jsfiddle.net/dXJb8/1/