logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: How to vertically center text and image?: msg#00054

Subject: Re: How to vertically center text and image?
At 2003-03-26 14:22 +0100, mes@xxxxxxxxxxxxxxxxxxxxxxxx wrote:
Hi,

my text is smaller as image,
how can i vertically center the text?
Example:
     .........
Text . Image . Text
     .........

An interesting challenge!


but not

Text ......... Text
     . Image .
     .........

XSL-FO "sits" graphics on top of lines oriented along the text ... not the other way around .... so I wouldn't have expected what you drew above, I always witness:

     .........
     . Image .
Text ......... Text

Using alignment-adjust you can change the default use of the text baseline for the bottom of the image, to be any other baseline for the bottom of the image ... but the image still sits *on top* of the given baseline.

I then noted that a length can be used for alignment-adjust ... but this means you will have to know a priori what the height of your graphic is.

I've attached the result shown for the following:

  <block space-before="1cm" font-size="20pt">
    -2cm : with a long enough sentence that will wrap to the next line
     in such a nature
    <external-graphic alignment-adjust="-2cm"
      src='url("tight.bmp")'/>
    to show how the text interacts with the image that has been aligned
  </block>

which gets you the result, but not by "vertically centring the text" which is what you asked for. I don't think there is a way to "vertically centre the text" ... I think you have to "vertically centre the graphic" by knowing the height of the graphic.

An interesting task!

I hope this helps.

................. Ken 

Attachment: test-align.gif
Description: GIF image


--
Upcoming hands-on in-depth XSLT/XPath and/or XSL-FO
                             North America:      June 16-20, 2003

G. Ken Holman                mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.         http://www.CraneSoftwrights.com/f/
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                      Definitive XSLT and XPath
ISBN 0-13-140374-5                              Definitive XSL-FO
ISBN 1-894049-08-X  Practical Transformation Using XSLT and XPath
ISBN 1-894049-10-1              Practical Formatting Using XSL-FO
Male Breast Cancer Awareness http://www.CraneSoftwrights.com/f/bc
<Prev in Thread] Current Thread [Next in Thread>