Twitter Bootstrap 2.0是否内置了对齐表格内容的内容?

Sib*_*Guy 23 css twitter-bootstrap twitter-bootstrap-2

通过设置"align"属性很容易对齐表,但是通过css对齐表有点hacky.是否内置支持在Twitter Bootstrap 2.0中对齐表格?

Ant*_*ift 24

没有内置任何东西来支持这个,但很容易添加如下内容:

.table th.rightCell,
.table td.rightCell {
  text-align: right;
}
Run Code Online (Sandbox Code Playgroud)

  • 另外,为了保持Bootstrap的命名约定并利用预先构建的`text-right`类,你应该将它添加到你自己的css:`.table th.text-right,.table td.text-right {text-align:对; 然后使用`<td class ="text-right"> Ta-dam </ td>` (25认同)

Ste*_*fan 12

Bootstrap的对齐类包括.text-right哪些集合text-align: right.

不幸的是,Bootstrap text-align: left为表格单元格设置,所以应用于.text-righta <td>没有任何影响:

<td class="text-right">
  Still left aligned
</td>
Run Code Online (Sandbox Code Playgroud)

但是,添加.text-right到单元格的块元素可以正常工作:

<td>
  <p class="text-right">Right aligned</p>
</td>
<td>
  <div class="text-right">Right aligned</div>
</td>
Run Code Online (Sandbox Code Playgroud)

  • 我正在使用Bootstrap 3.0,而`.text-right`在直接应用于`<td>`时效果很好. (11认同)