html - Btn-group 不拉伸(stretch)表格的宽度

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

我有一个带有表头和表行的表。标题是一个 btn 组,有 12 个按钮,类似于日历的月份,行有 31 列。我希望 btn-group 均匀分布并拉伸(stretch)表格行的整个宽度。我可以将 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 not full width

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

btn-group-justified

最佳答案

将以下类添加到父容器:.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

关于html - Btn-group 不拉伸(stretch)表格的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22469707/

相关文章:

html - 选择复选框输入时在图像上显示复选标记的最简单方法?

html - HTML代码中的空格和注释会影响页面渲染吗?

javascript - 创建带有动态背景图像的按钮

html - 如何保持响应图像相同的高度?

twitter-bootstrap - Bootstrap 3 datetimepicker 小部件位置

javascript - 如何检查文本输入是否在 ReactJS 中具有有效的电子邮件格式?

javascript - D3 - 如果文本以字符 'f' 开头,则附加矩形,否则附加圆形

javascript - 如果 ie6 做这个其他做那个。我怎样才能做到这一点

css - 如何在网站的移动版本中对齐 div 标签?

android - html5/android 触摸取消