Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 表布局奇偶行_Css_Asp.net_Css Tables - Fatal编程技术网

Css 表布局奇偶行

Css 表布局奇偶行,css,asp.net,css-tables,Css,Asp.net,Css Tables,我有一个表,它是由代码隐藏中的数据生成和填充的。我使用cssClass属性对它进行CSS类测试。现在我想给奇数行和偶数行不同的颜色。但是当我尝试使用普通的CSS代码时,它不起作用 这是我的CSS代码: <style> .test { tr:nth-child(even) {background: #CCC} tr:nth-child(odd) {background: #FFF} } </style> 您正在尝试嵌套CSS规则,这只可能在l

我有一个表,它是由代码隐藏中的数据生成和填充的。我使用cssClass属性对它进行CSS类测试。现在我想给奇数行和偶数行不同的颜色。但是当我尝试使用普通的CSS代码时,它不起作用

这是我的CSS代码:

<style>
.test
   {
    tr:nth-child(even) {background: #CCC}
    tr:nth-child(odd) {background: #FFF}
    }
</style>

您正在尝试嵌套CSS规则,这只可能在less/sass等中实现

试试这个:

.test tr:nth-child(even) {
background: #ccc;
}
.test tr:nth-child(odd) {
background: #fff;
}

除了IE8和更早版本之外,所有主要浏览器都支持:nth-child()选择器。

asp.net?经典asp?显示更多服务器端代码…你确定asp classic标记吗?“代码隐藏”是一个.net的东西。
.test tr:nth-child(even) {
background: #ccc;
}
.test tr:nth-child(odd) {
background: #fff;
}