[英]Align Checkbox with Label and Other Input Elements
Using Bootstrap 3, I am trying to align adjacent input elements with my label which is intended to be grouped with a checkbox. 使用Bootstrap 3,我试图将相邻的输入元素与我的标签对齐,该标签旨在与一个复选框分组。 At the moment, the checkbox and label are displayed a few pixels below the search query box and button. 目前,复选框和标签显示在搜索查询框和按钮下方几像素处。 The brand name also appears to be a few pixels higher. 品牌名称似乎也高出几个像素。
On Bootply: http://www.bootply.com/6tJSBqZ2d5 在Bootply上: http : //www.bootply.com/6tJSBqZ2d5
<div class="container row navbar navbar-inverse navbar-fixed-top">
<div class="navbar-header">
<a class="navbar-brand" href="#">Brand Name</a>
</div>
<form class="navbar-form navbar-right" id="search-form" method="get" name="search-form">
<div class="input-append">
<input class="form-control" id="query" name="query" placeholder="Search..." value=""> <button class="btn btn-info" type="submit"><span class="glyphicon glyphicon-search"></span></button>
<div class="checkbox">
<h3><span class="label label-default">Refresh
<input type="checkbox"></span></h3>
</div>
</div>
</form>
</div>
What is the proper way to align all elements and have them properly spaced? 对齐所有元素并使它们正确隔开的正确方法是什么?
The h3
is adding margin-top
and margin-bottom
, and the checkbox element that you have is 8px shorter than the other elements in the header. h3
添加margin-top
和margin-bottom
,并且您拥有的checkbox元素比标题中的其他元素短8px。
So if you add the h3-align
class as shown below to the h3
then it will be aligned: 因此,如果h3-align
如下所示的h3-align
类添加到h3
则它将被对齐:
CSS: CSS:
.h3-align {
margin-top: -4px;
margin-bottom: 0px;
}
HTML HTML
<h3 class="h3-align">
<span class="label label-default">Refresh
<input type="checkbox">
</span>
</h3>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.