【发布时间】:2021-12-23 16:01:53
【问题描述】:
我用HTML & CSS 成功了
table {
border: 1px solid;
border-collapse: collapse;
}
tr,
th,
td {
border: 1px solid;
padding: 10px;
}
<table>
<thead>
<tr>
<th>Asset \ File</th>
<th>Link</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
<tr>
<th> </th>
<th> </th>
<th> </th>
</tr>
<tr>
<th> </th>
<th> </th>
<th> </th>
</tr>
</tbody>
</table>
但我想让第一行的第一列分成两部分(对角线是连接两个角的直线段一个单元格) 就像我用 paint编辑 的图像:
为了制作这种风格,我选择了第一个 th:first-child 基于这个Answer
table {
border: 1px solid;
border-collapse: collapse;
}
tr,
th,
td {
border: 1px solid;
padding: 10px;
}
/*diagonal line*/
th:first-child {
background: linear-gradient(
to top right,
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, 0) calc(50% - 0.8px),
rgba(0, 0, 0, 1) 50%,
rgba(0, 0, 0, 0) calc(50% + 0.8px),
rgba(0, 0, 0, 0) 100%
);
}
<table>
<thead>
<tr>
<th>Asset \ File</th>
<th>Link</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
是否有任何其他方法或方法可以在不使用 background 和 linear-gradient 的情况下构建这种样式?
【问题讨论】:
标签: javascript html css diagonal