html - 如何使用:not selector with :nth-of-type

标签 html css css-selectors

我是关于设计表格的。我希望每个奇数行都有一个特定的背景,除了包含标题的第一行。

我使用了以下不起作用的代码:

.new-items-table tr:nth-of-type(odd):not(.new-items-table tr):nth-of-type(1)
{
background-color: red;
}

最佳答案

你可以这样做:

.new-items-table tr:nth-child(2n + 3) {
    background-color: red;
}

2n + 1odd 相同。 2n + 3 跳过前两行。

演示:http://jsfiddle.net/YVTTA/

关于html - 如何使用:not selector with :nth-of-type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18298999/

相关文章:

html - 将 CSS 应用于表单时遇到问题

html - 媒体查询根本不起作用

css - 在社交引擎中使用自定义布局?

java - 形状的 CSS 不适用于 javafx 中的文本区域

html - CSS 否定伪类 :not() for parent/ancestor elements

html - 有没有办法让 CSS 选择器在标题前放置 "-"?

jQuery - 如何在点击时检测视频栏播放按钮而不是视频本身

html - 如何将粘性导航栏的大小减半,以便只覆盖屏幕的一半,而不调整导航栏 img 的大小

html - 如何使用 chrome 开发工具根据 css class 或 id 查找元素?

css - 根据它的值设置 CSS 元素的样式