在Bootstrap 3中的输入字段上设置最大宽度

时间:2014-11-29 12:21:04

标签: twitter-bootstrap twitter-bootstrap-3

我有一个带有标题的表,我想在标题中添加输入以允许人们对表进行过滤。例如:

<table class="table table-condensed table-hover table-striped">
  <thead>
    <tr>
      <th>
        Date Created&nbsp;<button id="btnToggleFilterDateCreated" class="btn btn-xs btn-primary"><i class="fa fa-filter"></i></button>
        <div class="dateRangePickers">
          <div class="input-group date" id="dateCreatedStartFilterDiv">
            <span class="input-group-addon datepickerbutton">
              <span class="glyphicon glyphicon-calendar"></span>
            </span>
            <input type="text" id="dateCreatedStartFilter" size="10" maxlength="10" class="form-control" readonly="readonly" /><br/>
            <span class="input-group-addon">
              <span class="glyphicon glyphicon-remove"></span>
            </span>
          </div>
          <script type="text/javascript">
            $(function () {
              $('#dateCreatedStartFilterDiv').datetimepicker({ });
            });
          </script>
        </div>
      </th>
      <th></th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
  <thead>
  <tbody>
    ...
  <tbody>
</table>

jsFiddle http://jsfiddle.net/2u425cub/

但是,只要我将Bootstrap类应用于格式化,我的maxwidth就会被忽略,输入会将表列吹出来。有没有办法告诉Bootstrap尊重输入的10个字符大小限制?

1 个答案:

答案 0 :(得分:1)

我不确定我是否理解您的问题,但我认为您应该尝试重置输入和插件的宽度,请参阅:http://jsfiddle.net/2u425cub/1

这可以是,使用以下CSS代码:

.input-group .form-control, .input-group-addon, .input-group-btn {
    width:initial;
}