如何将nth-child放入CSS中的类中

时间:2018-01-04 18:39:38

标签: html css css-tables

我在表格中使用nth-child来定义标题和列的宽度,因此

th:nth-child(1), td:nth-child(1) { width: 72px !important; }
th:nth-child(2), td:nth-child(2) { width: 170px !important; }
th:nth-child(3), td:nth-child(3) { width: 95px !important; }
th:nth-child(4), td:nth-child(4) { width: 65px !important;}
th:nth-child(5), td:nth-child(5) { width: 90px  !important; }
th:nth-child(6), td:nth-child(6) { width: 90px  !important;}
th:nth-child(7), td:nth-child(7) { width: 90px  !important;}
th:nth-child(8), td:nth-child(8) { width: 90px  !important; }
th:nth-child(9), td:nth-child(9) { width: 90px  !important; }
th:nth-child(10), td:nth-child(10) { width: 90px  !important;}

但是我的页面中有多个表格,我只想将它应用到一个表格中。所以我想将它们放在像这样的类中

.myFixedHeaders{
th:nth-child(1), td:nth-child(1) { width: 72px !important;}
th:nth-child(2), td:nth-child(2) { width: 170px !important;}
th:nth-child(3), td:nth-child(3) { width: 95px !important;}
th:nth-child(4), td:nth-child(4) { width: 65px !important;}
th:nth-child(5), td:nth-child(5) { width: 90px  !important;}
th:nth-child(6), td:nth-child(6) { width: 90px  !important;}
th:nth-child(7), td:nth-child(7) { width: 90px  !important;}
th:nth-child(8), td:nth-child(8) { width: 90px  !important;}
th:nth-child(9), td:nth-child(9) { width: 90px  !important;}
th:nth-child(10), td:nth-child(10) { width: 90px  !important;}
}

但它不起作用。如何将它应用于一个表而不是全部三个?

0 个答案:

没有答案