这是否可以通过CSS实现?

我在努力

tr.classname {
  border-spacing: 5em;
}

但没有用。也许我做错了什么?


当前回答

你可以在桌子上做一些事情:

table {
  border-collapse: separate;
  border-spacing: 0 15px;
}

table selected:因为它将选择所有表,所以如果您想选择单个表,也可以这样做

<table class="res">

</table>

对于上面的html,您可以这样做,请注意,对于特定的表,如果需要,可以使用下面的方法。

.res {
      border-collapse: separate;
      border-spacing: 0 15px;
    }

参考:https://www.w3docs.com/snippets/css/how-to-create-space-between-rows-in-the-table.html

其他回答

我在与一个类似的问题作斗争时偶然发现了这一点。我发现Varun Natraaj的答案非常有用,但我会使用透明边框。

td { border: 1em solid transparent; }

透明边框仍具有宽度。

您可以尝试添加分隔符行:

html格式:

<tr class="separator" />

css:

table tr.separator { height: 10px; }

您有一个包含id相册的表,其中包含任何数据。。。我省略了trs和tds

<table id="albums" cellspacing="0">       
</table>

在css中:

table#albums 
{
    border-collapse:separate;
    border-spacing:0 5px;
}

只需将div放在td中,并设置以下div样式:

margin-bottom: 20px;
height: 40px;
float: left;
width: 100%;

表{边框折叠:单独;边框间距:0 1em;}