表格单元格中文本的垂直对齐

21

我想让第二个单元格中的文本底部对齐。 由于宽度不足,第一个单元格延伸到2行,这没问题。 但是第二个单元格中的文本只有一行,并且显示在单元格顶部。 如何将其底部对齐?

我尝试了在行、单元格和块级别上使用垂直对齐="bottom"、文本对齐="bottom"、文本对齐="end"等方法,但其中任何一个都没有起作用?!?

<fo:table font="normal 10 pt Arial, sans-serif" width="100%">
<fo:table-column column-width="40mm"/>
<fo:table-column column-width="130mm"/>
<fo:table-body>
<fo:table-row>
  <fo:table-cell padding-before="3pt" padding-after="3pt">
     <fo:block font-weight="bold">Pricing Rate in % p.a. / "Pensionssatz in % p.a.":</fo:block>
  </fo:table-cell>
  <fo:table-cell padding-before="3pt" padding-after="3pt">
    <fo:block> 
     **This text I want to be aligned to bottom (in the second line)** 
     </fo:block> 
  </fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
2个回答

41

在表格单元格上使用display-align="after"

<fo:table-cell padding-before="3pt" padding-after="3pt" display-align="after">
 <fo:block>
  **This text I want to be aligned to bottom (in the second line)**
 </fo:block> 
</fo:table-cell>

2
对于那些想要在fo:block/中垂直居中文本的人,这里有一个提示 - 在Apache FOP中它不起作用:http://xmlgraphics.apache.org/fop/compliance.html#fo-property-vertical-align - rbaleksandar
如果需要将文本垂直居中对齐,请使用以下代码...<fo:table-cell display-align="center"> - Lakshan Thilakarathne

1

如果有人遇到这个问题:

如果您有一张图片和文本,您不希望在图片后对齐而是在之前对齐:

<fo:table-cell display-align="before">
<!-- Your image & text separated in blocks -->
<fo:table-cell>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接