【问题标题】:Btn-group not stretching width of tableBtn-group 不拉伸表格的宽度
【发布时间】:2014-04-23 13:31:54
【问题描述】:

我有一个带有表格标题和表格行的表格。标题是一个 btn 组,有 12 个按钮,类似于日历的月份,行是 31 列。我希望 btn-group 均匀分布并拉伸表格行的整个宽度。我可以将 style="width:100px;" 添加到每个按钮,但这不是响应式的,而且我不一定知道整个表格的宽度。

任何人都可以看到我需要添加到我的代码中吗?

<thead>
    <tr>
      <th colspan="31">
        <div class="btn-toolbar" role="toolbar">
          <div class="btn-group">
            <button type="button" class="btn btn-default">Jan</button>
            <button type="button" class="btn btn-default">Feb</button>
            <button type="button" class="btn btn-default">Mar</button>
            <button type="button" class="btn btn-default active">Apr</button>
            <button type="button" class="btn btn-default">May</button>
            <button type="button" class="btn btn-default">Jun</button>
            <button type="button" class="btn btn-default">Jul</button>
            <button type="button" class="btn btn-default">Aug</button>
            <button type="button" class="btn btn-default">Sep</button>
            <button type="button" class="btn btn-default">Oct</button>
            <button type="button" class="btn btn-default">Nov</button>
            <button type="button" class="btn btn-default">Dec</button>
          </div>
        </div>
      </th>
    </tr>
  </thead>

这是我从 Bootstrap 3 默认值更改的 css 标签:

.btn-组 { 宽度:100%; }

.btn-工具栏 { 宽度:100%; }

如果我使用 btn-group-justified,它看起来像这样:

【问题讨论】:

    标签: html css twitter-bootstrap button twitter-bootstrap-3


    【解决方案1】:

    将以下类添加到父容器:.btn-group-justified

    <thead>
    <tr>
      <th colspan="31">
        <div class="btn-toolbar" role="toolbar">
          <div class="btn-group btn-group-justified">
            <button type="button" class="btn btn-default">Jan</button>
            <button type="button" class="btn btn-default">Feb</button>
            <button type="button" class="btn btn-default">Mar</button>
            <button type="button" class="btn btn-default active">Apr</button>
            <button type="button" class="btn btn-default">May</button>
            <button type="button" class="btn btn-default">Jun</button>
            <button type="button" class="btn btn-default">Jul</button>
            <button type="button" class="btn btn-default">Aug</button>
            <button type="button" class="btn btn-default">Sep</button>
            <button type="button" class="btn btn-default">Oct</button>
            <button type="button" class="btn btn-default">Nov</button>
            <button type="button" class="btn btn-default">Dec</button>
          </div>
        </div>
      </th>
    </tr>
    

    如需更多参考,请阅读文档的以下部分:

    http://getbootstrap.com/components/#btn-groups-justified

    【讨论】:

    • 并将每个 jsbin.com/witij/1/edit
    • 谢谢大家。添加带有 btn-group-justified 的额外 div 类解决了这个问题。
    • 如果这解决了您的问题,请将我的答案标记为正确答案。非常感谢。
    猜你喜欢
    • 2011-09-17
    • 2011-06-18
    • 2011-12-02
    • 2010-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多