不能在 <td> 上设置保证金既没有 CSS 也没有 cellpacing 属性的标签 [英] Cannot put margin on <td> tag with neither CSS nor cellspacing attribute

查看:13
本文介绍了不能在 <td> 上设置保证金既没有 CSS 也没有 cellpacing 属性的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论出于何种原因,我一直无法让任何表格单元格在它们之间留有边距.我希望表格单元格具有灰色背景颜色(在白色页面背景上),因此它看起来像它们之间带有白色的瓷砖.

For whatever reason, I have been unable to get any table cells to have margin between them. I want the table cells to have a grey background colour (over a white page background) so it looks like tiles with white between them.

我在 HTML 中尝试过,

I tried in the HTML,

<table cellspacing="3">

也在 CSS 中,

table td {
    margin:3px;
}

没有任何效果.细胞仍然粘在一起,就像一个大的灰色斑点.我在这里错过了非常非常基本的东西吗?

Nothing works. The cells are still stuck together, like one big grey blob. Am I missing something very very basic here?

实际代码如下:

<table width="100%" cellspacing="3">
    <tr>
        <th>Document Number</th>
        <th>BP Reference No.</th>
        <th>Posting Date</th>
        <th>Posting Week</th>
        <th>Customer/Vendor Code</th>
        <th>Customer/Vendor Name</th>
        <th>Item No.</th>
        <th>Item/Service Description</th>
        <th>Item Group</th>
        <th>Warehouse Code</th>
        <th>Remaining Open Quantity</th>
        <th>Line No.</th>
        <th>Sales Employee Name</th>
        <th>Stock</th>
        <th>Fill Rate</th>
        <th>1046</th>
        <th>1047</th>
        <th>1048</th>
        <th>1049</th>
        <th>1050</th>
        <th>1051</th>
        <th>1052</th>
        <th>1053</th>
        <th>1054</th>
        <th></th>
    </tr>
    <tr>
        <td>17272</td>
        <td>2244100</td>
        <td>5/24/2010</td>
        <td>22</td>
        <td>NYST</td>
        <td>NYSTROM INC.</td>
        <td>NYM118SX26DSTKS01</td>
        <td>Nystrom, Mort. 1-1/8'', Schl C~K, US26D, ST cam, 5pin, KS #43758</td>
        <td>Mort Cylinders</td>
        <td>US1</td>
        <td>1000</td>
        <td>3</td>
        <td>KRE Management 1</td>
        <td>0</td>
        <td>100</td>
        <td>1000</td>
        <td>0</td>
        <td>0</td>
        <td>0</td>
        <td>0</td>
        <td>0</td>
        <td>0</td>
        <td>0</td>
        <td>0</td>
        <td></td>
    </tr>
</table>

推荐答案

如果有人仍然遇到这个问题,请在您的 CSS 样式表中尝试:

If someone still has this problem, try this in your CSS stylesheet:

table {
  border-collapse: separate;
  border-spacing: 10px 5px;
}

边框间距的值是两个长度测量值.水平的值首先出现并应用于列之间.第二个测量是应用在行之间.

The values for border-spacing are two length measurements. The horizontal value comes first and applies between columns. The second measurement is applied between rows.

如果您提供一个值,它将被水平和垂直使用.默认设置为 0,导致边框在表格的内部网格上加倍.

If you provide one value, it will be used both horizontally and vertically. The default setting is 0, causing the borders to double up on the inside grid of the table.

这篇关于不能在 &lt;td&gt; 上设置保证金既没有 CSS 也没有 cellpacing 属性的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆