假设我有一个包含大量数据的table
元素。
table {
background-color: skyblue;
width: 100%;
margin: auto;
text-align: center;
}

<table>
<tbody>
<tr>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
</tr>
<tr>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
</tr>
<tr>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
</tr>
<tr>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
</tr>
<tr>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
</tr>
<tr>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
<td>My Name</td>
</tr>
</tbody>
</table>
&#13;
在每个偶数border-style: dashed; border-color: black; border-size: 3px;
上设置td
边框的最佳方法是什么。
请解释一下。
答案 0 :(得分:6)
你可以尝试:
td:nth-child(even) {
border-style: dashed;
border-color: black;
border-size: 3px;
}