我想zebra-stripe一个html表而不使用任何js东西或编写服务器端代码来为表行生成偶数/奇数类.是否有可能使用原始css?
K. *_*ert 124
CSS3选择器可以:
tr:nth-child(even) {
background-color: red;
}
tr:nth-child(odd) {
background-color: white;
}
Run Code Online (Sandbox Code Playgroud)
据caniuse.com称,现在每个浏览器都支持它.