23

It is easy to align table by setting "align" attribute, but table aligning by css is a bit hacky. Is there built-in support for tables aligning in Twitter Bootstrap 2.0?

Stefan
  • 96,300
  • 10
  • 122
  • 186
SiberianGuy
  • 22,118
  • 44
  • 135
  • 253
  • I'm not sure this is 'hacky'. Bootstrap is just that a bootstrap to get things started and is meant to be built upon. – Ant Swift Oct 29 '12 at 10:33

3 Answers3

24

There is nothing built in to support this but it is very easy to add something like:

.table th.rightCell,
.table td.rightCell {
  text-align: right;
}
ebottard
  • 1,987
  • 2
  • 11
  • 14
Ant Swift
  • 17,721
  • 10
  • 35
  • 55
  • 25
    Alternatively to keep Bootstrap's naming conventions and to utilize the pre-built `text-right` class, you should add this to your own css: `.table th.text-right, .table td.text-right { text-align: right; }` and then use `Ta-dam` – Attila Fulop May 08 '13 at 04:11
12

Bootstrap's alignment classes include .text-right which sets text-align: right.

Unfortunately Bootstrap sets text-align: left for table cells so applying .text-right to a <td> doesn't have any effect:

<td class="text-right">
  Still left aligned
</td>

Adding .text-right to a block element inside the cell however does work:

<td>
  <p class="text-right">Right aligned</p>
</td>
<td>
  <div class="text-right">Right aligned</div>
</td>
Stefan
  • 96,300
  • 10
  • 122
  • 186
0

For "td" I used this which is included in bootstrap css:

<td class="pagination-centered">
trante
  • 30,976
  • 45
  • 174
  • 260