Arc*_*ger 5 html css asp.net-mvc
我在网上找到了很多关于为备用表格行着色的文章。如果我想为各行使用不同的颜色,我该怎么做?

<table class="table1">
<tr>
<th>Name</th>
<th>Surname</th>
<th>Email</th>
</tr>
@{ foreach (var p in Model.People)
{ <tr>
<td>@p.Name</td>
<td>@p.Surname</td>
<td>@p.Number</d>
</tr>
}
}
</table>
Run Code Online (Sandbox Code Playgroud)
你可以在你的CSS中有
\n\n.table1 tr:nth-child(1) { background:blue; }\n.table1 tr:nth-child(2) { background:red; }\n.table1 tr:nth-child(3) { background:orange; }\n...\n\xe2\x80\x8b\nRun Code Online (Sandbox Code Playgroud)\n\n请参阅演示\n http://jsfiddle.net/wnCgL/
\n\n编辑
\n\n使用 jQuery,使用随机颜色函数
\n\n$(function() {\n $(\'.table1\').find(\'tr\').each(\n function() {\n $(this).css(\'background\', get_random_color()); \n });\n});\nRun Code Online (Sandbox Code Playgroud)\n\n\n