我想将输入框设为:
但得到:
有没有办法可以删除其间的额外空格,并在不使用css边距的情况下获得所需的输出。我的代码如下:
<div class="row">
<div class="col-md-2 employerEin">
<input type="text" name="employerEIN1" maxlength="2" size="2" value=""
class="form-control" id="employerEIN1" title="EIN">
</div>
<span class="col-md-1 employerEin">-</span>
<div class="col-md-3">
<input type="text" name="employerEIN2" maxlength="7" size="7" value=""
class="form-control" id="employerEIN2" title="EIN">
</div>
</div>
答案 0 :(得分:2)
只需将.form-inline
课程添加到<form>
<div class="row">
<form class="form-inline">
<div class="form-group">
<input type="text" name="employerEIN1" maxlength="2" size="2" value="" class="form-control" id="employerEIN1" title="EIN">
-
<input type="text" name="employerEIN2" maxlength="7" size="7" value="" class="form-control" id="employerEIN2" title="EIN">
</div>
</form>
</div>
编辑:由于OP的评论
添加了其他代码只需将.form-inline
类添加到封闭div中,使这两个字段内联,然后根据需要继续添加其他字段
<div class="row">
<!-- add the .form-inline class to the enclosing div -->
<div class="form-group form-inline">
<input type="text" name="employerEIN1" maxlength="2" size="2" value="" class="form-control" id="employerEIN1" title="EIN">
-
<input type="text" name="employerEIN2" maxlength="7" size="7" value="" class="form-control" id="employerEIN2" title="EIN">
</div>
<!-- add other form elements as needed -->
<div class="form-group">
<input type="text" name="field3" maxlength="2" value="" class="form-control">
</div>
<div class="form-group">
<input type="text" name="field4" maxlength="7" value="" class="form-control">
</div>
</div>