<table id="first"style="width:310px;border:2px;margin-top:10px;margin-left:auto;margin-right:auto;background:#F7F7F7;">
<tr>
<td style="height:50px;width:100%;"></td>
</tr>
<tr><td>
<table style="width:100%;">
<tr>
<td id="_1"style="background:#FF70C6;width:151px;height:20px;cursor:pointer;">Low/empty</td>
<td id="_5"style="background:#FF5053;width:151px;height:20px;cursor:pointer;">Unusable</td>
</tr>
<tr>
<td id="_2"style="background:#0099FF;width:151px;height:20px;cursor:pointer;">Unclean</td>
<td id="_5"style="background:#FF5053;width:151px;height:20px;cursor:pointer;">Unusable</td>
</tr>
<tr>
<td id="_3"style="background:#00D07B;width:151px;height:20px;cursor:pointer;">Damaged</td>
<td id="_5"style="background:#FF5053;width:151px;height:20px;cursor:pointer;">Unusable</td>
</tr>
<tr>
<td id="_4"style="background:#FF5053;width:151px;height:20px;cursor:pointer;">Unusable</td>
<td id="_5"style="background:#FF5053;width:151px;height:20px;cursor:pointer;">Unusable</td>
</tr>
<tr>
<td id="_5"style="background:#FF5053;width:151px;height:20px;cursor:pointer;">Unusable</td>
<td id="_5"style="background:#FF5053;width:151px;height:20px;cursor:pointer;">Unusable</td>
</tr>
</table>
</td></tr>
<tr><td id="ad"style="background:url('R/ad.png');width:100%;height:113px;cursor:pointer;"></td></tr>
<tr><td style="height:20px;width:100%;text-align:right;">text</td></tr>
我在 <td>
中有一张 table .家长<td>
有某种单元格间距/填充边框的东西,它会稍微插入子表(顶部、左侧、右侧、底部)。
虽然它在每个方向上只有 2px,但当我看到它时,我的眼球(猛烈地)吐了出来,因为我在 <td>
中有一张图片在下面,子表的单元格外壁应该与它齐平。有谁知道表格的 CSS,因为我发现 w3scools/css-tricks 不是很有用(或者可能是我无法正确地形成有用的连贯查询字符串供 Google 搜索)?
最佳答案
几个选项:
- CSS:
<a href="http://www.w3.org/wiki/CSS/Properties/border-collapse" rel="noreferrer noopener nofollow">border-collapse</a>: collapse
( fiddle ) - 过时的表属性:
<a href="http://www.w3.org/TR/html401/struct/tables.html#adef-cellpadding" rel="noreferrer noopener nofollow">cellpadding</a> = 0
和<a href="http://www.w3.org/TR/html401/struct/tables.html#adef-cellspacing" rel="noreferrer noopener nofollow">cellspacing</a> = 0
(fiddle)。
关于html - <td> 中的表格每边被压扁 2px,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17684746/