html - 表格第一列占用太多宽度?

标签 html css html-table

我正在尝试制作一个两栏的问题和答案表。第一列应仅包含问题编号,以便实际问题和答案在第二列中对齐。

但是,我希望问题编号紧挨着问题,这样看起来就像一个句子。由于某种原因,包含数字的第一列占用了太多宽度。

如何让它只占据所需的宽度?

.title {
  font-size: 24px;
  font-weight: 500;
  letter-spacing: .3px;
  padding-bottom: 32px;
  color: #333;
}
<table border="0" cellpadding="0" cellspacing="0" class="faq" width="666">
  <tbody>
    <tr>
      <td class="title">FAQ</td>
    </tr>
    <tr>
      <td class="question">1.</td>
      <td class="question">What happens when the wild tigers purr?</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td class="answer">Sixty-Four comes asking for bread. If Purple People Eaters are real… where do they find purple people to eat?</td>
    </tr>
  </tbody>
</table>

最佳答案

因为你

<td class="title">FAQ</td>

也在该列中,并且占用了很多空间。解决这个问题的一种方法是将其从表中删除。修改后的版本如下:

<div class="title">FAQ</div>    

<table border="0" cellpadding="0" cellspacing="0" class="faq" width="666">
    <tbody>
        <tr>
            <td class="question">1.</td>
            <td class="question">What happens when the wild tigers purr?</td>
        </tr>
        <tr>
           <td>&nbsp;</td>
           <td class="answer">Sixty-Four comes asking for bread. If Purple People Eaters are real… where do they find purple people to eat?</td>
        </tr>
    </tbody>
</table>

您可能遇到的另一个问题是您的 <tr>标签无法与您的问题/答案对齐一起使用。首先尝试快速制定餐 table 计划,因为实际上很难做到正确。

关于html - 表格第一列占用太多宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50957284/

相关文章:

javascript - 使用 jquery load 将文本插入到 div 中

javascript - 为什么不能用 document.getElementById 代替 JavaScript 中的 $?

javascript - Internet Explorer 8 标准模式下的表格性能不佳

javascript - VUE | JavaScript : How to access a key as a date format?

html - 不同行的不同边框间距

css - 响应式网页设计 100% 包装

javascript - 单击播放后如何加载视频?

javascript - 为什么部署(串联、缩小)AngularJS + RequireJS 应用程序不起作用?

每行的 HTML 悬停样式

html - 无法垂直对齐 float 元素和周围元素