html - 不规则的表格 div
问题描述
我想将最后一个 div 放在每一行的行下。是否有可能在不中断的情况下实现这一目标display: table
?我不想为此添加第二行。我试图在下图中解释我的问题
我的html
<table>
<thead>
<tr>
<td>id</td>
<td>creator</td>
<td>receiver</td>
<td>start_date</td>
<td>end_date</td>
<td>daily_pay</td>
<td>total_votes</td>
<td>permlink</td>
<td></td>
</tr>
</thead>
<tbody>
<tr>
<td>3</td>
<td>aaaabbbb</td>
<td>aaaabbbb</td>
<td>
{new Date(
'2015-05-01T00:00:00'
).toLocaleString()}
</td>
<td>
{new Date(
'2019-06-01T00:00:00'
).toLocaleString()}
</td>
<td>100.000</td>
<td>0</td>
<td>
<a href="javascript:void(0)">link</a>
</td>
<td>testing stuff</td>
</tr>
<tr>
<td>3</td>
<td>aaaabbbb</td>
<td>aaaabbbb</td>
<td>
{new Date(
'2015-05-01T00:00:00'
).toLocaleString()}
</td>
<td>
{new Date(
'2019-06-01T00:00:00'
).toLocaleString()}
</td>
<td>100.000</td>
<td>0</td>
<td>
<a href="javascript:void(0)">link</a>
</td>
<td>
Lorem ipsum dolor sit amet consectetur
adipisicing elit. Reprehenderit amet
ipsa adipisci praesentium unde, illum
iure fuga necessitatibus dolorem. Sed
ipsam facilis modi eligendi cumque
maiores quae repellat incidunt error!
</td>
</tr>
</tbody>
</table>
解决方案
如果您将最后一个单元格 a<td>
放在一个新的<tr>
跨所有 8 列中,那将是最语义化的colspan
。
tbody td {
padding: .5em;
}
tbody tr:nth-child(odd) {
background-color: #ccc;
}
<table>
<thead>
<tr>
<th>id</th>
<th>creator</th>
<th>receiver</th>
<th>start_date</th>
<th>end_date</th>
<th>daily play</th>
<th>total votes</th>
<th>permalink</th>
</tr>
</thead>
<tbody>
<tr>
<td>aaaaaaaa</td>
<td>bbbbbbbb</td>
<td>mike n</td>
<td>01/15/2000</td>
<td>01/15/2001</td>
<td>1000.00</td>
<td>0</td>
<td><a href="#">link</a></td>
</tr>
<tr>
<td colspan="8">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Labore quod officiis nostrum provident distinctio consequatur nobis vero vel dignissimos magnam. Harum velit mollitia veniam, provident, labore repellat beatae nisi error!
</td>
</tr>
<tr>
<td>aaaaaaaa</td>
<td>bbbbbbbb</td>
<td>mike n</td>
<td>01/15/2000</td>
<td>01/15/2001</td>
<td>1000.00</td>
<td>0</td>
<td><a href="#">link</a></td>
</tr>
<tr>
<td colspan="8">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Labore quod officiis nostrum provident distinctio consequatur nobis vero vel dignissimos magnam. Harum velit mollitia veniam, provident, labore repellat beatae nisi error!
</td>
</tr>
</tbody>
</table>
推荐阅读
- bash - sh 文件中的错误替换错误
- amazon-web-services - S3 错误:使用嵌套堆栈部署 CFN 模板时访问被拒绝
- azure - 在用户未登录时通过 Microsoft Graph API 访问日历
- linux - 我需要在 bash 中的用户输入上从一个日期读取文件名到另一个日期
- flutter - 如何提升下拉列表,因为它的某些项目被键盘隐藏?
- c# - EF Core Postgres Update-Database 正在尝试创建已经存在的数据库
- filter - 通过矩阵中的多个维度表过滤事实表(Power BI / Power Pivot)
- django - ImportError:无法从“geodjango”导入名称“docker_config”
- python - 我怎样才能矢量化这个操作?
- azure - Azure 数据工厂中的 Jira 链接服务错误