这里用css3中结构伪类:nth-child(i) 和nth-of-type(i)的组合来实现配色表。注意:nth-of-type(odd) 选中奇数行 ,nth-of-type(even)选中偶数行。
<!DOCTYPE html>
<html>
<head>
<title>配色表</title>
<meta charset="utf-8">
<style type="text/css">
tr td{width: 80px; height: 30px;}
tr th{width: 80px; height: 30px;}
/*第一行:tr:nth-child(i) td:nth-of-type(j)选中第i行的第j个td,由于每行第一个都是th,这里要过滤掉th,所以用nth-of-type */
tr:nth-child(2) td:nth-of-type(1){background:hsl(120,100%,100%)}
tr:nth-child(2) td:nth-of-type(2){background:hsl(120,75%,100%)}
tr:nth-child(2) td:nth-of-type(3){background:hsl(120,50%,100%)}
tr:nth-child(2) td:nth-of-type(4){background:hsl(120,25%,100%)}
tr:nth-child(2) td:nth-of-type(5){background:hsl(120,0%,100%)}
/*第二行*/
tr:nth-child(3) td:nth-of-type(1){background:hsl(120,100%,90%)}
tr:nth-child(3) td:nth-of-type(2){background:hsl(120,75%,90%)}
tr:nth-child(3) td:nth-of-type(3){background:hsl(120,50%,90%)}
tr:nth-child(3) td:nth-of-type(4){background:hsl(120,25%,90%)}
tr:nth-child(3) td:nth-of-type(5){background:hsl(120,0%,90%)}
/*第三行*/
tr:nth-child(4) td:nth-of-type(1){background:hsl(120,100%,80%)}
tr:nth-child(4) td:nth-of-type(2){background:hsl(120,75%,80%)}
tr:nth-child(4) td:nth-of-type(3){background:hsl(120,50%,80%)}
tr:nth-child(4) td:nth-of-type(4){background:hsl(120,25%,80%)}
tr:nth-child(4) td:nth-of-type(5){background:hsl(120,0%,80%)}
/*第三行*/
tr:nth-child(4) td:nth-of-type(1){background:hsl(120,100%,80%)}
tr:nth-child(4) td:nth-of-type(2){background:hsl(120,75%,80%)}
tr:nth-child(4) td:nth-of-type(3){background:hsl(120,50%,80%)}
tr:nth-child(4) td:nth-of-type(4){background:hsl(120,25%,80%)}
tr:nth-child(4) td:nth-of-type(5){background:hsl(120,0%,80%)}
/*第三行*/
tr:nth-child(4) td:nth-of-type(1){background:hsl(120,100%,80%)}
tr:nth-child(4) td:nth-of-type(2){background:hsl(120,75%,80%)}
tr:nth-child(4) td:nth-of-type(3){background:hsl(120,50%,80%)}
tr:nth-child(4) td:nth-of-type(4){background:hsl(120,25%,80%)}
tr:nth-child(4) td:nth-of-type(5){background:hsl(120,0%,80%)}
/*第三行*/
tr:nth-child(4) td:nth-of-type(1){background:hsl(120,100%,80%)}
tr:nth-child(4) td:nth-of-type(2){background:hsl(120,75%,80%)}
tr:nth-child(4) td:nth-of-type(3){background:hsl(120,50%,80%)}
tr:nth-child(4) td:nth-of-type(4){background:hsl(120,25%,80%)}
tr:nth-child(4) td:nth-of-type(5){background:hsl(120,0%,80%)}
/*第三行*/
tr:nth-child(4) td:nth-of-type(1){background:hsl(120,100%,80%)}
tr:nth-child(4) td:nth-of-type(2){background:hsl(120,75%,80%)}
tr:nth-child(4) td:nth-of-type(3){background:hsl(120,50%,80%)}
tr:nth-child(4) td:nth-of-type(4){background:hsl(120,25%,80%)}
tr:nth-child(4) td:nth-of-type(5){background:hsl(120,0%,80%)}
/*第三行*/
tr:nth-child(4) td:nth-of-type(1){background:hsl(120,100%,80%)}
tr:nth-child(4) td:nth-of-type(2){background:hsl(120,75%,80%)}
tr:nth-child(4) td:nth-of-type(3){background:hsl(120,50%,80%)}
tr:nth-child(4) td:nth-of-type(4){background:hsl(120,25%,80%)}
tr:nth-child(4) td:nth-of-type(5){background:hsl(120,0%,80%)}
/*第四行*/
tr:nth-child(5) td:nth-of-type(1){background:hsl(120,100%,70%)}
tr:nth-child(5) td:nth-of-type(2){background:hsl(120,75%,70%)}
tr:nth-child(5) td:nth-of-type(3){background:hsl(120,50%,70%)}
tr:nth-child(5) td:nth-of-type(4){background:hsl(120,25%,70%)}
tr:nth-child(5) td:nth-of-type(5){background:hsl(120,0%,70%)}
/*第五行*/
tr:nth-child(6) td:nth-of-type(1){background:hsl(120,100%,60%)}
tr:nth-child(6) td:nth-of-type(2){background:hsl(120,75%,60%)}
tr:nth-child(6) td:nth-of-type(3){background:hsl(120,50%,60%)}
tr:nth-child(6) td:nth-of-type(4){background:hsl(120,25%,60%)}
tr:nth-child(6) td:nth-of-type(5){background:hsl(120,0%,60%)}
/*第六行*/
tr:nth-child(7) td:nth-of-type(1){background:hsl(120,100%,50%)}
tr:nth-child(7) td:nth-of-type(2){background:hsl(120,75%,50%)}
tr:nth-child(7) td:nth-of-type(3){background:hsl(120,50%,50%)}
tr:nth-child(7) td:nth-of-type(4){background:hsl(120,25%,50%)}
tr:nth-child(7) td:nth-of-type(5){background:hsl(120,0%,50%)}
/*第七行*/
tr:nth-child(8) td:nth-of-type(1){background:hsl(120,100%,40%)}
tr:nth-child(8) td:nth-of-type(2){background:hsl(120,75%,40%)}
tr:nth-child(8) td:nth-of-type(3){background:hsl(120,50%,40%)}
tr:nth-child(8) td:nth-of-type(4){background:hsl(120,25%,40%)}
tr:nth-child(8) td:nth-of-type(5){background:hsl(120,0%,40%)}
/*第八行*/
tr:nth-child(9) td:nth-of-type(1){background:hsl(120,100%,30%)}
tr:nth-child(9) td:nth-of-type(2){background:hsl(120,75%,30%)}
tr:nth-child(9) td:nth-of-type(3){background:hsl(120,50%,30%)}
tr:nth-child(9) td:nth-of-type(4){background:hsl(120,25%,30%)}
tr:nth-child(9) td:nth-of-type(5){background:hsl(120,0%,30%)}
/*第九行*/
tr:nth-child(10) td:nth-of-type(1){background:hsl(120,100%,20%)}
tr:nth-child(10) td:nth-of-type(2){background:hsl(120,75%,20%)}
tr:nth-child(10) td:nth-of-type(3){background:hsl(120,50%,20%)}
tr:nth-child(10) td:nth-of-type(4){background:hsl(120,25%,20%)}
tr:nth-child(10) td:nth-of-type(5){background:hsl(120,0%,20%)}
/*第十行*/
tr:nth-child(11) td:nth-of-type(1){background:hsl(120,100%,10%)}
tr:nth-child(11) td:nth-of-type(2){background:hsl(120,75%,10%)}
tr:nth-child(11) td:nth-of-type(3){background:hsl(120,50%,10%)}
tr:nth-child(11) td:nth-of-type(4){background:hsl(120,25%,10%)}
tr:nth-child(11) td:nth-of-type(5){background:hsl(120,0%,10%)}
/*第十一行*/
tr:nth-child(12) td:nth-of-type(1){background:hsl(120,100%,0%)}
tr:nth-child(12) td:nth-of-type(2){background:hsl(120,75%,0%)}
tr:nth-child(12) td:nth-of-type(3){background:hsl(120,50%,0%)}
tr:nth-child(12) td:nth-of-type(4){background:hsl(120,25%,0%)}
tr:nth-child(12) td:nth-of-type(5){background:hsl(120,0%,0%)}
</style>
</head>
<body>
<table border="1px">
<tr>
<th>亮度↓饱和度→</th>
<th>100%</th>
<th>75%</th>
<th>50%</th>
<th>25%</th>
<th>0%</th>
</tr>
<tr>
<th>100%</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>90%</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>80%</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>70%</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>60%</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>50%</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>40%</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>30%</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>20%</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>10%</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<th>0%</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>
运行结果: