#table_replacer{display:table;}.tr_replacer {border: 1px solid #123456;margin-bottom: 5px;}/*DO NOT USE display:table-row! It will destroy the border and the margin*/.td_replacer{display:table-cell;}
<table><tr><td>Some text - 1</td><td>Some text - 1</td></tr><tr><td>Some text - 2</td><td>Some text - 2</td></tr><tr><td>Some text - 3</td><td>Some text - 3</td></tr></table>
td {padding:5px 8px;border:2px solid blue;background:#E0E0E0} /* lets say the cells all have this padding and border, and the gaps should be white */
tr.gapbefore td {overflow:visible}tr.gapbefore td::before,tr.gapbefore th::before{content:"";display:block;position:relative;z-index:1;width:auto;height:0;padding:0;margin:-5px -10px 5px; /* 5px = cell top padding, 10px = (cell side padding)+(cell side border width)+(table side border width) */border-top:16px solid white; /* the size & color of the gap you want */border-bottom:2px solid blue; /* this replaces the cell's top border, so should be the same as that. DOUBLE IT if using border-collapse:separate */}
行间隙的外观可以通过在应该有下一个间隙的单元格上使用底部边框来实现,即border-bottom:solid white 5px;
以下是创建屏幕截图的代码:
<style>table.class1 {text-align:center;border-spacing:0 0px;font-family:Calibri, sans-serif;}
table.class1 tr:first-child {background-color:#F8F8F8; /* header row color */}
table.class1 tr > td {/* firefox has a problem rounding the bottom corners if the entire row is colored *//* hence the color is applied to each cell */background-color:#BDE5F8;}
table.class1 th {border:solid #A6A6A6 1px;border-bottom-width:0px; /* otherwise borders are doubled-up */border-right-width:0px;padding:5px;}
table.class1 th:first-child {border-radius: 5px 0 0 0;}
table.class1 th.last {border-right-width:1px;border-radius: 0 5px 0 0;}
/* round the bottom corners */table.class1 tr:last-child > td:first-child {border-radius: 0 0 0 5px;}
table.class1 tr:last-child > td:last-child {border-radius: 0 0 5px 0;}
/* put a line at the start of each new group */td.newgroup {border-top:solid #AAA 1px;}
/* this has to match the parent element background-color *//* increase or decrease the amount of space by changing 5px */td.endgroup {border-bottom:solid white 5px;}
</style>
<table class="class1"><tr><th>Group</th><th>Item</th><th class="last">Row</th></tr><tr><td class="newgroup endgroup">G-1</td><td class="newgroup endgroup">a1</td><td class="newgroup endgroup">1</td></tr><tr><td class="newgroup">G-2</td><td class="newgroup">b1</td><td class="newgroup">2</td></tr><tr><td>G-2</td><td>b2</td><td>3</td></tr><tr><td class="endgroup">G-2</td><td class="endgroup">b3</td><td class="endgroup">4</td></tr><tr><td class="newgroup">G-3</td><td class="newgroup">c1</td><td class="newgroup">5</td></tr><tr><td>G-3</td><td>c2</td><td>6</td></tr></table>