如何将td的宽度设置为0

时间:2022-11-03 11:26:33

how can I set the width of an td to 0? I have a td without any content in it but it has always a width of 2px.

如何将td的宽度设置为0?我有一个没有任何内容的td但它的宽度总是2px。

My first suspicion was the border-spacing property but setting it to 0 doesn't help neither.

我的第一个怀疑是边界间距属性,但将其设置为0并没有帮助。

    <table>
    <tr>
        <td></td>
        <td></td>
        <td></td>
    </tr>
</table>

See Sample

3 个解决方案

#1


5  

Set tds padding to 0 adding padding: 0; to your td css rule.

将tds填充设置为0添加填充:0;你的td css规则。

#2


2  

You'll need to remove the padding. ( td { padding: 0; })

您需要删除填充。 (td {padding:0;})

Modern web browsers make it quite easy to track down questions like this. For example, using the Chrome Developer tools you can highlight the element and take a look at the Metrics tab and find out what is causing your width.

现代网络浏览器可以很容易地找到这样的问题。例如,使用Chrome开发者工具,您可以突出显示该元素,并查看“指标”标签,找出导致宽度的原因。

如何将td的宽度设置为0

#3


1  

Your css should be:

你的CSS应该是:

td{
  background-color: red;
  padding: 0;
}

Update Fiddle: http://jsfiddle.net/PZkSa/5/

更新小提琴:http://jsfiddle.net/PZkSa/5/

#1


5  

Set tds padding to 0 adding padding: 0; to your td css rule.

将tds填充设置为0添加填充:0;你的td css规则。

#2


2  

You'll need to remove the padding. ( td { padding: 0; })

您需要删除填充。 (td {padding:0;})

Modern web browsers make it quite easy to track down questions like this. For example, using the Chrome Developer tools you can highlight the element and take a look at the Metrics tab and find out what is causing your width.

现代网络浏览器可以很容易地找到这样的问题。例如,使用Chrome开发者工具,您可以突出显示该元素,并查看“指标”标签,找出导致宽度的原因。

如何将td的宽度设置为0

#3


1  

Your css should be:

你的CSS应该是:

td{
  background-color: red;
  padding: 0;
}

Update Fiddle: http://jsfiddle.net/PZkSa/5/

更新小提琴:http://jsfiddle.net/PZkSa/5/