I have an HTML table with large number of rows, and I need to right align one column.
I know the following ways,
..
-
You could use the nth-child
pseudo-selector. For example:
table.align-right-3rd-column td:nth-child(3)
{
text-align: right;
}
Then in your table do:
...
Edit:
Unfortunately, this only works in Firefox 3.5. However, if your table only has 3 columns, you could use the sibling selector, which has much better browser support. Here's what the style sheet would look like:
table.align-right-3rd-column td + td + td
{
text-align: right;
}
This will match any column preceded by two other columns.
- 热议问题