我将如何选择表中的所有孩子们除了第一个和最后一个? 我已经试过这一点,但它最终选择不在第一所有的儿童和所有儿童未持续,这最终被所有的孩子:
table.programs tr td:not(:first-child), table.programs tr td:not(:last-child) {
}
我想既不是第一个也不是最后一个所有儿童。 我怎样才能做到这一点?
我将如何选择表中的所有孩子们除了第一个和最后一个? 我已经试过这一点,但它最终选择不在第一所有的儿童和所有儿童未持续,这最终被所有的孩子:
table.programs tr td:not(:first-child), table.programs tr td:not(:last-child) {
}
我想既不是第一个也不是最后一个所有儿童。 我怎样才能做到这一点?
使用两个:not()
选择器结合,由此参照匹配两者,即元素匹配既不用作操作数的选择器的元件:not()
table.programs td:not(:first-child):not(:last-child)
jQuery的解决方案是好的,但如果你想这样做的纯CSS我建议你到规则适用于整个表,然后重新设置他们的第一个和最后一个孩子。 即:
table.programs tr td {
/* your rules here */
}
table.programs tr:first-child td:first-child,
table.programs tr:last-child td:last-child {
/* reset your rules here */
}
的jsfiddle演示
我想,这应该为你工作:
table.programs tr td:not(:first-child,:last-child)