如何选择一行中的第一个和最后一个 TD
?
tr > td[0],
tr > td[-1] {
/* styles */
}
最佳答案
您可以使用 :first-child
和 :last-child
伪选择器:
tr td:first-child,
tr td:last-child {
/* styles */
}
这应该适用于所有主流浏览器,但 IE7 在动态添加元素时会出现一些问题(在 IE6 中不起作用)。
关于css - 如何连续选择第一个和最后一个TD?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7228800/