html - 如何将有序列表项表与数字对齐?

标签 html css html-table html-lists

我有一个有序的表列表,其中包含 1 行和 2 列,使用下面的代码。

我试图让表格段落的第一行与类似于普通列表项的数字对齐。由于某种原因,它没有对齐,数字显示在底部。

我如何才能 1. 将表格行段落与类似于第一项的数字对齐,以及 2. 将“56 次引用”段落与表格中的其他 td 对齐。

谢谢!

<ol>
  <li>
    <p>This is what a normal item</p>
    <p>looks</p>
    <p>like</p>
  </li>
  <li>
    <table>
      <tr>
        <td>
          <p>This is what a table item</p>
          <p>looks</p>
          <p>like</p>
        </td>
        <td>
          <p>56 Citations</p>
        </td>
      </tr>
      </table>
  </li>
</ol>

The rending of the html in Firefox

最佳答案

td元素中使用vertical-align: baseline,像这样:

td {
  vertical-align: baseline;
}
<ol>
  <li>
    <p>This is what a normal item</p>
    <p>looks</p>
    <p>like</p>
  </li>
  <li>
    <table>
      <tr>
        <td>
          <p>This is what a table item</p>
          <p>looks</p>
          <p>like</p>
        </td>
        <td>
          <p>56 Citations</p>
        </td>
      </tr>
    </table>
  </li>
</ol>

关于html - 如何将有序列表项表与数字对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66287266/

相关文章:

html - 带有 CSS 的表格的棋盘样式。如何?

jquery - 使用 Jquery 并排响应和重新调整两个 div 的大小

css - 使用 CSS,如何根据我悬停的单元格更改表格行的背景颜色?

javascript - 使用 Javascript 在 HTML5 时间字段中输入时间

javascript - 如何使用javascript更改占位符的颜色?

html - 如何使用 <link> 引用 HTML 中的另一个 .css 文件

javascript - 如何修复表格的标题

php - 排序 html php mysql 表的问题

javascript - 重叠绝对定位的 div

html - 创建一条中间有圆圈的线