将样式应用于表格中第n个内的div

时间:2014-12-01 07:42:22

标签: javascript jquery html css html-table

这是我的 Fiddle

在这里,我需要将风格应用于价值"测试"这是给定div的第n个孩子。

注意我不应该使用类,因为我使用的是flexigrid。

我该怎么做?

这是我的风格

table, td, th {
    border: 1px solid green;
}

th {
    background-color: green;
    color: white;
}
th:nth-child(2) {
    background : red !important;
}

2 个答案:

答案 0 :(得分:0)

你的问题确实有点模糊。 但是你不需要一个类来设置这个数据表的样式。

ROW STYLE

tr:nth-child(2) { background : red !important; }

COLUMN STYLE

td:nth-child(2) { background : red !important; }

HEADING STYLE

th:nth-child(2) { background : red !important; }

答案 1 :(得分:0)

你可以试试这个:

table, td, th {
    border: 1px solid green;
}

th {
    background-color: green;
    color: white;
}
th:nth-child(2) div {
    background : red;
}