【问题标题】:Dynamic cell spacing in HTML tableHTML表格中的动态单元格间距
【发布时间】:2022-07-07 00:06:20
【问题描述】:

好吧,我什至不知道这是否可能,但我正在尝试使用<table> 来完成以下设计:

我知道只使用<span> 会更容易,甚至不用担心表格,但我认为表格在这里实际上是有意义的。

这是我目前所拥有的:

table {
  text-align: left;
}
<table>
  <tr>
    <th>Population:</th>
    <td>334,300</td>
  </tr>
  <tr>
    <th>Region:</th>
    <td>Europe</td>
  </tr>
  <tr>
    <th>Capital:</th>
    <td>Reykjavík</td>
  </tr>
</table>

【问题讨论】:

  • 不,table 就是这样工作的,我建议你重新考虑你的方法

标签: html css


【解决方案1】:

您可以重置 thtddisplay

table {
  text-align: left;
}
th,td {display:inline;}
<table>
  <tr>
    <th>Population:</th>
    <td>334,300</td>
  </tr>
  <tr>
    <th>Region:</th>
    <td>Europe</td>
  </tr>
  <tr>
    <th>Capital:</th>
    <td>Reykjavík</td>
  </tr>
</table>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多