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?
Asked
Active
Viewed 1.9k times
23
-
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 Answers
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;
}
-
25Alternatively 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>
![](../../users/profiles/477037.webp)
Stefan
- 96,300
- 10
- 122
- 186
-
11I'm using Bootstrap 3.0, and `.text-right` works perfectly when applied directly to a `
`. – Jeremy Visser May 17 '14 at 11:11
0
For "td" I used this which is included in bootstrap css:
<td class="pagination-centered">
![](../../users/profiles/429938.webp)
trante
- 30,976
- 45
- 174
- 260