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

标签 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>

最佳答案

使用输入组:

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

关于html - 如何摆脱输入和日历图标之间的空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28228548/

相关文章:

javascript - 如何使用 Bootstrap 按钮组和 AngularJS 在页面之间导航

html - 将搜索图标放在文本框中

javascript - 如何让 jQuery 在管理区工作?

html - 更改链接到图像的页面背景?

html - 制作通用 db_access 文件

javascript - 如何进行响应式设计,使 H2 在 1 行 DIV 中获得最大字体大小?

jquery - 如何在 jquery 中将一个 div 的最小高度更改为另一个 div 的高度 - 代码不起作用

asp.net - 如何正确编码 mailto 链接?

javascript - 按钮显示进度

html - 标题内容对齐/定位