Hobbes
Hobbes

Reputation: 2115

How can I baseline-align two blocks with different font-height?

I've got a table with 2 cells. One cell contains a number, the other contains text in a larger font. I want to align the baselines of the two texts. I've tried lots of combinations of display-align, vertical-align, alignment-baseline etc. Nothing seems to work: the blocks are always aligned as if alignment-baseline="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>

I can fake the correct alignment by putting a padding on the block in column 1, but I'd rather use a non-hack solution.

Upvotes: 1

Views: 272

Answers (1)

Tony Graham
Tony Graham

Reputation: 8068

Use relative-align="baseline". See https://www.w3.org/TR/xsl11/#relative-align

relative-align exists because of this problem. It applies only to fo:table-cell and fo:list-item since they are (or were expected to be) the only places where it's needed.

Upvotes: 1

Related Questions