I have an HTML table with large number of rows, and I need to right align one column.
I know the following ways,
..
-
If it's always the third column, you can use this (assuming table class of "products"). It's kinda hacky though, and not robust if you add a new column.
table.products td+td+td {
text-align: right;
}
table.products td,
table.products td+td+td+td {
text-align: left;
}
But honestly, the best idea is to use a class on each cell. You can use the col
element to set the width, border, background or visibility of a column, but not any other properties. Reasons discussed here.
- 热议问题