温馨提示:本文翻译自stackoverflow.com,查看原文请点击:其他 - How can I let html table borders merge into each other in css
css html html-table

其他 - 我怎样才能让HTML表格边框在CSS中相互合并

发布于 2020-03-28 23:23:59

在当前的项目中,我有一个三列的表。

<table>
    <tr>
        <th>Datum</th>
        <th>Entschuldigt?</th>
        <th>Vermerkt von</th>
    </tr>
</table>

我当前的表格样式表如下:

th {
    border-bottom: 1px solid black;
}

td + td {
    border-left: 1px solid black;
    border-right: 1px solid black;
}

现在桌子看起来像这样 current_table

现在,我想删除那些小的空间,以使列分隔符和标题分隔符很牢固,而不是虚线。非常感谢您的帮助

查看更多

查看更多

提问者
byTreneib
被浏览
16
Omri Attiya 2020-01-31 15:04

您需要border-collapse: collapse在桌子上使用

th {
  border-bottom: 1px solid black;
}

td+td {
  border-left: 1px solid black;
  border-right: 1px solid black;
}

table {
   border-collapse: collapse;
}
<table>
  <tr>
    <th>Datum</th>
    <th>Entschuldigt?</th>
    <th>Vermerkt von</th>
  </tr>
  <tr>
    <td>item 1</td>
    <td>item 2</td>
    <td>item 3</td>
  </tr>
  <tr>
    <td>item 1</td>
    <td>item 2</td>
    <td>item 3</td>
  </tr>
</table>