简体   繁体   中英

Align vertically two elements in Raphael

In this jsFiddle I hava a RaphaelJS canvas with a text and a rectangle where both should start at the same x/y coordinates (see that coordinates are 20/20 in both elements).

To align horizontally I use { 'text-anchor': 'start' } but I cannot find the equivalent to align vertically.

How to make both the text and the rectangle start at the same y coordinate?

解决方案:使用getBBox()获取文本,然后将文本高度除以2,然后添加到矩形y坐标。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM