我希望每个单元格之间有4个左右的像素空间。我希望灰色标题有空格而不是灰色块。我试过玩游戏(background-clip:padding-box; padding:14px; margin等),但无法弄清楚如何在div表格中的单元格之间放置几个像素。我该怎么做?
演示问题http://jsfiddle.net/EJBnm/
<div class="TableBox">
<div>
<div>Head</div> <div>Bigger Head</div> <div>Medium</div>
</div>
<div>
<div>First</div> <div>Second</div> <div>Third</div>
</div>
<div>
<div>First</div> <div>Second</div> <div>Third</div>
</div>
<div>
<div>First</div> <div>Second</div> <div>Third</div>
</div>
</div>
CSS:
.TableBox {display: table;}
.TableBox > div {display: table-row; border-spacing: 5px}
.TableBox > div >div {display: table-cell; margin: 4px;}
.TableBox > div:nth-child(even){ color: red; }
.TableBox > div:nth-child(1){ background-color: #666666; color:white; border-spacing: 15px; background-clip:padding-box; padding: 14px; margin:0 20px}
答案 0 :(得分:6)
将border-spacing: 4px;
添加到.TableBox
课程而不是<tr>
答案 1 :(得分:0)
您可以使用透明(或白色边框)代替边距:http://jsfiddle.net/jfsWc/
.TableBox > div >div {display: table-cell; border:4px solid transparent}