html - <td> 中的表格每边被压扁 2px

标签 html css

<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 搜索)?

最佳答案

几个选项:

  1. CSS:<a href="http://www.w3.org/wiki/CSS/Properties/border-collapse" rel="noreferrer noopener nofollow">border-collapse</a>: collapse ( fiddle )
  2. 过时的表属性:<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/

相关文章:

html - 在全尺寸横幅上从方框向右移动

javascript - jQuery Mobile 1.4.2 - 带图标的单选按钮

javascript - 单击时,Youtube/SoundCloud视频在新选项卡中打开

javascript - 如何只显示来自不同页面的 HTML div 或 td 元素?

javascript - "crop"图像的脚本间歇性运行。

html - 对于具有相同标记的 2 个不同的 div,我的 div 的对齐方式不同

php - 如何在内联 block 中输出 mysqli 查询行?

c# - 使用 Html.Raw 将 ASP.NET 模型序列化为 JSON 时出现 Razor 语法错误

jquery - 从选择中更改类别

javascript - 如何使用 Bootstrap 禁用幻灯片中的左右箭头