问题描述
我有一个包含 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>
解决方法
在 vertical-align: baseline
元素中使用 td
,如下所示:
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>