[英]Table spacing in html
For what ever reason, I get a small gap in between the two TD cells (Lines dont touch). 出于某种原因,我在两个TD单元之间得到了一个小的间隙(线不接触)。 There is no padding or margin on that side... I did this collapsing idea.
那边没有填充物或边缘......我做了这个崩溃的想法。
Why is it there? 为什么会这样? http://jsfiddle.net/CKy6U/
http://jsfiddle.net/CKy6U/
My html: 我的HTML:
<table>
<tr>
<td>
TEST CELL 1
</td>
<td>
TEST CELL 2
</td>
</tr>
</table>
my CSS: 我的CSS:
table
{
width: 100%;
}
tr
{
border-bottom: 1px solid Black;
}
td
{
border-collapse: separate;
border-spacing: 0px;
border-left: 1px solid Black;
border-bottom: 1px solid Black;
padding: 3px;
width: 50%;
}
My Result: 我的结果:
You have to add border-collapse: collapse
in your table
or cellspacing="0"
in your html table. 您必须在
table
添加border-collapse: collapse
或在html表格中添加cellspacing="0"
。
css CSS
table {
width: 100%;
border-collapse: collapse;
}
html: HTML:
<table cellspacing="0">
Both solutions should work. 这两种方案都应该有效 But use
border-colapse
cause as @Mooseman comment cellspacing
is obsolete in html5. 但是使用
border-colapse
导致@Mooseman注释cellspacing
在html5中已经过时了。
Add border-right: 0px;
添加
border-right: 0px;
to and remove border-collapse: separate
from the td
. to和remove
border-collapse: separate
td
border-collapse: separate
。 Add border-collapse: collapse
to the table
. 添加
border-collapse: collapse
到table
。
Fiddle: http://jsfiddle.net/CKy6U/7/ 小提琴: http : //jsfiddle.net/CKy6U/7/
使用normalize.css或css reset我也会添加
<table cellspacing="0" cellpadding="0"> ... </table>
Remove the border-collapse
on the td
and add it to the table
删除
td
上的border-collapse
并将其添加到table
table{
width: 100%;
border-collapse: collapse;
}
tr{
border-bottom: 1px solid black;
}
td{
border-spacing: 0px;
border-left: 1px solid black;
border-bottom: 1px solid black;
padding: 3px;
width: 50%;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.