You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React+MUI样式组件实现表格仅首行与第二行、页脚间加间距

问题

我尝试结合使用cell spacing与border-collapse,但间距会应用到整个表格。我只想在表格首行与第二行之间、以及页脚处添加间距。当前使用React的MUI样式组件开发,曾尝试用两个表格实现需求,但不符合代码规范;也试过border-spacing、border-collapse等多种CSS规则。

期望实现的表格样式

期望的表格样式

当前示例代码

HTML

<table class="tableClass">
  <thead>
    <tr>
      <th>header 1</th>
      <th>header 2</th>
      <th>header 3</th>
      <th>header 4</th>
      <th>header 5</th>
    </tr>
  </thead>
  
  <tbody>
    <td>content 1</td>
    <td>content 2</td>
    <td>content 3</td>
    <td>content 4</td>
    <td>content 5</td>
  </tbody>
</table>

CSS

.tableClass{ border-collapse: separate; border-spacing: 10px 0px;}

更新(解决方案)

保留空单元格并应用empty-cell: hide规则可实现所需效果。感谢帮助,也为表述不清致歉。

内容的提问来源于stack exchange,提问作者GeekDev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 04:54:53