Html <td> 之间的空格。为什么以及如何删除?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17837106/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 11:28:41  来源:igfitidea点击:

Space between <td>. Why and how can I remove?

htmlcssstyles

提问by Kuba ?ukowski

I create "normal" table and all TD's have "border: 1px solid #e6e6e6" and "margin: 0". TR and TABLE have too "margin/padding: 0" but I still have space between TDs like here: h

我创建了“普通”表,所有 TD 都有“边框:1px 实心 #e6e6e6”和“边距:0”。TR 和 TABLE 有太多“边距/填充:0”但我仍然有像这里的 TD 之间的空间:h

enter image description here

在此处输入图片说明

Why? :)

为什么?:)

<td></td>

http://jsfiddle.net/VfSdV/

http://jsfiddle.net/VfSdV/

回答by Brian Phillips

Since cellspacingand cellpaddingare no longer supported in HTML5, use the following CSS:

由于cellspacingcellpadding不再在HTML5支持,使用下面的CSS:

table {
  border-collapse: collapse;
}

jsfiddle

提琴手

回答by Keith

Use cellspacing and cellpadding :

使用 cellpacing 和 cellpadding :

 <table cellspacing="0" cellpadding="0">

 </table>

回答by CSS2013

After much trial and error, I ended up using most of what everyone else mentioned plus some from other sites. This worked for me.

经过多次反复试验,我最终使用了其他人提到的大部分内容以及其他网站的一些内容。这对我有用。

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

td,img { 
padding:0px; 
border-width:0px; 
margin:0px; 
}

回答by Etienne Arthur

Could you try this ?

你能试试这个吗?

table#table {
    border-spacing: 0;
}

This piece of css works for me. Hope it helps :).

这段css对我有用。希望能帮助到你 :)。

回答by user3378188

Try this answer too

也试试这个答案

table.tableclassname td
{
    display: inline-block;
}