有没有一种方法来设置整列的文本对齐方式在一个表中?方法来、文本、方式

2023-09-11 23:33:13 作者:她好无恙.

有没有一种简单的方法,所有的细胞在第二列的文本对齐方式设置为右键

Is there a simple way to set the text alignment of all cells in the second column to right?

或者说是唯一的办法是设置对齐列中每个单元格?

Or is the only way is to set the alignment for each cell in the column?

(不幸的是,没有在Firefox支持的 COL 标记的调整属性。)

(Unfortunately, the align attribute of the col tag is not supported in Firefox.)

推荐答案

一类添加到每个细胞中的第2列。

Add a class to every cell in the 2nd column.

.second {
   text-align: right;
}

您也可以使用CSS3。

You could also use CSS3.

tr td:nth-child(2) { /* I don't think they are 0 based */
   text-align: right;
}

(它不会工作与< = IE8)

(It won't work in <= IE8)