如何基线对齐两个具有不同字体高度的块?
How can I baseline-align two blocks with different font-height?
我有一个有 2 个电池的 table。一个单元格包含一个数字,另一个包含较大字体的文本。我想对齐两个文本的基线。我已经尝试了很多显示对齐、垂直对齐、对齐基线等的组合。似乎没有任何效果:块总是对齐的,就像对齐基线="center".
<fo:table>
<fo:table-column column-width="20mm" column-number="1"/>
<fo:table-column column-width="100mm" column-number="2"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell column-number="1">
<fo:block font-size="9pt" line-height="22pt">1.</fo:block>
</fo:table-cell>
<fo:table-cell column-number="2">
<fo:block font-size="20pt"line-height="22pt">Title</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-body>
</fo:table>
我可以通过在第 1 列的块上填充来伪造正确的对齐方式,但我宁愿使用非 hack 解决方案。
使用relative-align="baseline"
。参见 https://www.w3.org/TR/xsl11/#relative-align
relative-align
因为这个问题而存在。它仅适用于 fo:table-cell
和 fo:list-item
,因为它们是(或预期是)唯一需要它的地方。
我有一个有 2 个电池的 table。一个单元格包含一个数字,另一个包含较大字体的文本。我想对齐两个文本的基线。我已经尝试了很多显示对齐、垂直对齐、对齐基线等的组合。似乎没有任何效果:块总是对齐的,就像对齐基线="center".
<fo:table>
<fo:table-column column-width="20mm" column-number="1"/>
<fo:table-column column-width="100mm" column-number="2"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell column-number="1">
<fo:block font-size="9pt" line-height="22pt">1.</fo:block>
</fo:table-cell>
<fo:table-cell column-number="2">
<fo:block font-size="20pt"line-height="22pt">Title</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-body>
</fo:table>
我可以通过在第 1 列的块上填充来伪造正确的对齐方式,但我宁愿使用非 hack 解决方案。
使用relative-align="baseline"
。参见 https://www.w3.org/TR/xsl11/#relative-align
relative-align
因为这个问题而存在。它仅适用于 fo:table-cell
和 fo:list-item
,因为它们是(或预期是)唯一需要它的地方。