假设我有一个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>
在每个
border-style: dashed; border-color: black; border-size: 3px;
上设置td
边界的最佳方法是什么。请解释一下。
最佳答案
您可以尝试:
td:nth-child(even) {
border-style: dashed;
border-color: black;
border-size: 3px;
}
关于html - 如何在表格上设置边框,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39439055/