Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anything built into to Twitter Bootstrap 2.0 to align table contents?

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?

like image 690
SiberianGuy Avatar asked Jun 23 '12 11:06

SiberianGuy


2 Answers

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; } 
like image 184
Ant Swift Avatar answered Sep 19 '22 15:09

Ant Swift


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>
like image 37
Stefan Avatar answered Sep 19 '22 15:09

Stefan