html - td 没有与 btn-group 对抗

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

<td> 中的文本未居中对齐(valign),直接与 btn-group 对齐最后<td> .

参见示例:https://jsfiddle.net/rsf1f6wn/

如何解决这个问题?

<table id="myDataTable" class="table" cellspacing="0" width="100%">
  <thead>
    <tr>
      <th>Name</th>
      <th>Location</th>
      <th>Orders</th>
      <th></th>
    </tr>
  </thead>

  <tbody>
    <tr class="active">
      <td><a href="#">FirstName Lastame</a></td>
      <td>USA</td>
      <td>10</td>
      <td>
        <div class="btn-group pull-right">
          <button type="button" class="btn btn-sm">Edit</button>
          <button type="button" class="btn btn-sm">Add</button>
        </div>
      </td>
    </tr>
  </tbody>
</table>

最佳答案

您需要为以下类提供vertical-align: middle:

.table thead>tr>th,
.table tbody>tr>th,
.table tfoot>tr>th,
.table thead>tr>td,
.table tbody>tr>td,
.table tfoot>tr>td {
  vertical-align: middle;
}

这也有一个特殊性问题。因此,上面的代码可以以正确的特异性获取正确的目标元素。

fiddle :https://jsfiddle.net/9x0f7r3c/

关于html - td 没有与 btn-group 对抗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34774976/

相关文章:

javascript - 如何使用javascript将文本转换为二进制

html - CSS:自动计算元素的高度以匹配背景图像

css - 带有 Bootstrap 的边框布局

javascript - 单击下拉列表中的按钮而不关闭它时触发 AJAX 操作

javascript - 在 Bootstrap 模式中将 javascript ID 转换为 PHP 变量

jquery - slider 有 1px chrome 错误

javascript - React - 文档标题添加图标

javascript - 使用 jquery 使一个函数在具有相同类的所有 div 中工作

html - Bootstrap ipad 不像移动设备那样显示

php - HTTP ://localhost/appears before path