如何摆脱输入和日历图标之间的空间

时间:2015-01-30 03:02:40

标签: html css twitter-bootstrap

更新

enter image description here

在实现此代码后,我正在获得:

<div class="col-xs-5">
   <div class="form-group">
      <label for="" class="col-xs-5 control-label">Contract Date Signed:</label>
      <div class="col-xs-5">
         @Html.EditorFor(m => m.ContractDateSigned, new { htmlAttributes = new { @Value = Convert.ToDateTime(Model.ContractDateSigned).ToShortDateString(), @class = "form-control" } }) 
         @Html.ValidationMessageFor(m => m.ContractDateSigned, "", new { @class = "text-danger"
         })
         <span class="input-group-addon"><span class="glyphicon glyphicon-calendar" aria-hidden="true"></span></span>
      </div>
   </div>
</div>

如何摆脱输入和日历图标之间的空间?

enter image description here

这是我的html使用:

<div class="col-xs-5">
   <div class="form-group">
      <label for="" class="col-xs-5 control-label">Contract Date Signed:</label>
      <div class="col-xs-5">
         @Html.EditorFor(m => m.ContractDateSigned, new { htmlAttributes = new { @Value = Convert.ToDateTime(Model.ContractDateSigned).ToShortDateString(), @class = "form-control" } })                                                
         @Html.ValidationMessageFor(m => m.ContractDateSigned, "", new { @class = "text-danger" })
      </div>
      <span class="btn btn-default"><span class=" fa fa-calendar"></span></span>
   </div>
</div>

2 个答案:

答案 0 :(得分:2)

使用输入组:

http://getbootstrap.com/components/#input-groups

<div>
  <div class="form-group">
    <label for="" class="col-xs-5 control-label">
      Contract Date Signed:
    </label>
    <div class="input-group col-xs-5">
      <input class="form-control">
      <span class="input-group-addon">
        <i class="glyphicon glyphicon-calendar" aria-hidden="true"></i>
      </span>
    </div>
  </div>
</div>

见这个jsfiddle:

http://jsfiddle.net/21Lfnq4e/

enter image description here

答案 1 :(得分:0)

<div class="col-xs-5">
   <div class="form-group">
      <label class="control-label">Contract Date Signed:</label>
      <div class="input-group">
        <input type="text" class="form-control">
         <span class="input-group-addon"><span class="glyphicon glyphicon-calendar" aria-hidden="true"></span></span>
      </div>
      </div>
</div>