【问题标题】:twitter-bootstrap max width of input fieldtwitter-bootstrap 输入字段的最大宽度
【发布时间】:2012-08-20 15:25:11
【问题描述】:

我使用最新的 twitter 引导框架进行了以下设置:

http://jsfiddle.net/hfexR/2/

我现在希望输入字段在旁边没有按钮时采用最大宽度。

如何使用纯 css 或 twitter-bootstrap 本身来做到这一点?

像 inline-block 这样的东西应该去,我现在不明白......

【问题讨论】:

  • 您不应将.span4.well 结合使用。您是否尝试过使用.row-fluid 并跨越井内?
  • 1.将 span 和 wells 结合起来有什么问题 2. 你能给我举个例子吗

标签: css twitter-bootstrap width


【解决方案1】:

你可以像fiddle那样使用te class input-block-level

<div class="container">
  <div class="span4 well">
    <form class="form-search">
      <input type="text" class="input-block-level search-query">
    </form>
    <form class="form-search">
      <input type="text" class="input-medium search-query">
      <button type="submit" class="btn">Cancel</button>
    </form>
  </div>
</div>

【讨论】:

【解决方案2】:

编辑:自 bootstrap v3 以来,类已经发展,因此使用 col-xx-X 类来获得下面解释的结果(可能需要进一步更改)


Live demo (jsfiddle)

您可以使用.row-fluid 并使用.spanX 使输入填充其容器:

<form class="form-search">
  <div class="row-fluid">
      <input type="text" class="input-medium search-query span12">
  </div>
</form>
<form class="form-search">
  <div class="row-fluid">
      <input type="text" class="input-medium search-query span8">
      <button type="submit" class="btn span4">Cancel</button>
  </div>
</form>

似乎需要对按钮/输入组合进行一些修复:

/* May not be the best way, not sure if BS has a better solution */
/* Fix for combining input and button spans in a row */
.row-fluid > input + button[class*="span"] {
    float: none;           /* Remove the */
    display: inline-block; /* floating   */
    margin-left: 0;        /* Stick it to the left */
}

最后一件事,你不应该将.spanX.well 组合在一起,因为padding 和边框和其他东西,这里是an example of why (jsfiddle)

【讨论】:

  • 在 bootstrap 3 中删除了 span 类。
  • @krock 确实课程已经改变,但答案的精神是一样的,请参阅 col-xx-X classes and associates
猜你喜欢
  • 2019-04-01
  • 2012-07-12
  • 1970-01-01
  • 2012-06-13
  • 1970-01-01
  • 2021-12-05
  • 2013-09-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多