jquery - 如何使每张 table 的背景色重复出现?

标签 jquery html css css-tables

我想要每张 table 的“斑马”外观。所以已经为每个表格设置的背景颜色需要重复出现,而不是像现在这样纯色。我如何才能使其他表格行都是白色的?

http://jsfiddle.net/Lance_Bitner/v8buo90L/

.tabs > div table tr td {
        background: rgba(232, 240, 250, .5);
    }
.tabs > div:nth-child(2) table tr td {
        background: rgba(254, 217, 209, .5);
    }
.tabs > div:nth-child(3) table tr td {
        background: rgba(230, 198, 229, .5);
    }

最佳答案

不需要 jquery 只需将 :nth-child(even) 添加到每一行就可以了。

.tabs > div table tr:nth-child(even) td {
  background: rgba(232, 240, 250, .5);
}

.tabs > div:nth-child(2) table tr:nth-child(even) td {
  background: rgba(254, 217, 209, .5);
}

.tabs > div:nth-child(3) table tr:nth-child(even) td {
  background: rgba(230, 198, 229, .5);
}

你的 JQuery 也很好,只需要删除相关的 css (.tabs > div:nth-child(*) table tr td) 就可以了,尽管它们都是蓝色阴影.

关于jquery - 如何使每张 table 的背景色重复出现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37346941/

相关文章:

javascript - 从右向左滑动垂直菜单 > Jquery

html - 目标 ="_blank"与目标 ="_new"

css - ionic2 html页面按钮底部

javascript - 如何为多个元素附加 onclick 操作

html - 无法将背景图像显示到浏览器的全屏并使其响应

javascript - 将 JavaScript 更改为 jQuery 不起作用

javascript - 使用 JavaScript/KnockoutJS 查找列表中的特定属性

css - IE 问题 : Div positioning

jquery 仅在几毫秒内显示隐藏的 div

javascript - jQuery - 了解步进动画函数内部的 `this`