html - 如何在 CSS 中堆叠表格中仅一行的 TD 元素?
问题描述
理想情况下,我会使用 div,但这不是一个选项。
我也需要在桌子的一排内堆积或堆积 TD,而其余部分保持原样。
带显示:块;它有点工作,除了所有的 TD 堆叠只有一列的宽度。(见代码)
有没有办法在 css 中堆叠 TD 并使它们成为 100% 的行?
提前谢谢了!
.red {
border: solid red 0.25em ;
display: block;
}
.blue {
border: solid blue 0.25em ;
display: block;
}
td {
border: solid grey 0.25em ;
}
<table>
<tr>
<td>top row</td>
<td>top row</td>
<td>top row</td>
</tr>
<tr>
<td class="blue" > needs to go on top of the other td</td>
<td class="red" >
</td>
<td class="red">
</td>
</tr>
</table>
解决方案
不知道是不是你需要的。但是,如果你需要一个 tr 放在桌子上,你可以像下面这样使用thead
<table>
<caption>Council budget (in £) 2018</caption>
<tbody>
<tr>
<th scope="row">Donuts</th>
<td>3,000</td>
</tr>
<tr>
<th scope="row">Stationery</th>
<td>18,000</td>
</tr>
</tbody>
<thead>
<tr>
<th scope="col">Items</th>
<th scope="col">Expenditure</th>
</tr>
</thead>
</table>
推荐阅读
- c# - 如何从 CS 文件访问生成的 XAML 项
- reactjs - React:我应该使用什么来与 API 交互?
- java - 如果有新的应用版本可用,如何触发更新(来自 GITHUB)
- angular - HTTP 错误 502.5 - ANCM 进程外启动失败
- android - 离线 DataBinding = enable 导致错误:找不到 databinding-runtime.jar
- python - 在 pycharm 中获取代理错误。设置已应用但仍会出现
- java - 在 selenium 中循环一个 try 和 catch 语句
- java - 如何在 Java POJO(文本、图像、Pdf、Doc 等)中为消息指定单个属性/字段?
- jupyter-notebook - 使用 jupyter 小部件动态生成与搜索相结合的复选框
- c - 打印强数(c编程)