html - 如何在表格中添加水平线

标签 html css html-table border

我想要两个记录之间的水平线和一些额外的底部填充来添加一个符号

编辑/更新:

我正在硬编码我想要的内容如下

table {
  border: 1px solid black;
  padding: 0em 2em;
}

tr {
  border: 1px solid black;
  padding: 0em 2em;
}

tr:nth-child(3) {
  margin: 0px;
  padding: 0px;
}

tr:nth-child(7) {
  background-color: red
}

td:nth-child(21) {
  border-bottom: 1px solid blue;
}
<table>
  <tr>
    <th colspan="2">Old_records</th>
    <td>32</td>
  </tr>
  
  <tr>
    <th>Records_fetched</th>
    <td colspan="2">100</td>
  </tr>
  
  <tr>
    <td colspan="3"> -----------------------------</td>
  </tr>
  
  <tr>
    <th>Sum </th>
    <td colspan="2">132</td>
  </tr>

  <tr>
    <th>New_records</th>
    <td></td>
    <td>80</td>
  </tr>
  
  <tr>
    <td colspan="3"> -----------------------------</td>
  </tr>

  <tr>
    <th>Differnce </th>
    <td colspan="2">52</td>
  </tr>
</table>

我仍然需要添加符号,并且我有更好的方法来添加边框而不是这一行 <tr><td colspan="3"> -----------------------------</td></tr>

有人可以建议我如何正确地做到这一点吗?

最佳答案

tr 中添加边框并为表格应用 border-collapse:collapse

table { 
  border: 1px solid black;
  padding:0em 2em;
  border-collapse: collapse;
}
tr {
  border-bottom: 1px solid black;
}
td {
  padding: 2em;
}
<table>
  <tr>
    <th>Old_records</th>
    <td> 32 </td>
  </tr>
  <tr>
    <th>Records_fetched</th>
    <td>100</td>
  </tr>
  <tr>
    <th>NEw_records</th>
    <td>80</td>
  </tr>
</table>

关于html - 如何在表格中添加水平线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45481806/

相关文章:

html - 仅针对其填充和内容制定 td 契约(Contract)

jquery - <a href ="xyz.php"> 的目标到 php 页面上的特定 div,而不重定向 php 页面

javascript - 如何将 Title 属性添加到动态填充的 <SELECT>

html - 如何使用CSS在盒子周围绘制一半边框

css - Chrome 与 Firefox 与 Internet Explorer 的图像定位

html - 带有两个标题行的粘性表格标题

html - 滚动覆盖 div 而不滚动整个页面

html - 防止最后一行的 flex 元素变得比其他 flex 元素大

html - 如何在 asp.net MVC 中隐藏 Webgrid 中的列?

angular - 如何在 Angular Dart 中使用 Angular Material 表