<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
table tr:nth-child(even)>td {
background-color: #fff;
}
table tr:nth-child(odd)>td {
background-color: #ccc;
}
</style>
</head>
<body>
<table>
<tr>
<th>Header</th>
</tr>
<tr>
<td>Data1</td>
</tr>
<tr>
<td>Data2</td>
</tr>
<tr>
<td>Data3</td>
</tr>
<tr>
<td>Data4</td>
</tr>
<tr>
<td>Data5</td>
</tr>
</table>
</body>
</html>
效果:
写一个表格,奇数行背景是白色,偶数行背景是#ccc
原文:https://www.cnblogs.com/Friday1/p/14708367.html