-1

我有一个有 10 列的表。我如何编写为TD2 或 7 位置的所有 s 设置样式的 css 类?

4

1 回答 1

4

就像是:

tr td:nth-child(2), tr td:nth-child(7) {
    /* style here */
}

IE8 不支持它。但这里有一个非常好的 polyfill:ie9.js

备择方案:

  1. 使用 jQuery
  2. 为每个 2nd 和 7th td 添加一个自定义类
于 2012-10-08T08:27:02.990 回答