Is there a way to set the text alignment of entire column in a table?

前端 未结 6 1311
南笙
南笙 2020-12-29 01:11

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

6条回答
  •  梦毁少年i
    2020-12-29 01:39

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

    .second {
       text-align: right;
    }
    

    You could also use CSS3.

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

    (It won't work in <= IE8)

提交回复
热议问题