In RaphaelJS, how to align rotated text to the bottom?

浪子不回头ぞ 提交于 2019-12-24 17:23:25

问题


Using the following code, and inspired by this question, I managed to have vertical column headers in an HTML table, compatible with Internet Explorer. Now the last detail I need to set is the header vertical alignement : I'd like to have my headers fixed to the bottom of their row.

$(document).ready(function(){
$('tr th div').each(function (index, div){
R = Raphael($(div).attr('id'), 10, 200);
R.text(5, 100, $(div).find('span').text())
.rotate(-90, true);
$(div).find('span').hide();
});
});

With this code, I am able to get this result :

Rotated Headers not aligned http://ompldr.org/vZnhhdw

As you can see, the headers are rotated but not aligned to the bottom of their cells, I'd like them to be. I tried using :

vertical-align: bottom;

But that didn't change anything.

And also to add this after or before the .rotate instruction in the JS code :

.attr({'text-anchor': 'end'});

When placed before the .rotate instruction, this just made the headers disappear. When placed after the .rotate instruction, I had better results, but still not what I want, as the headers are vertically aligned based on their last character :

Vertical Align Attempt http://ompldr.org/vZnhiOQ

How could I align these headers to the bottom of the first row, in order to get such result ?

Thanks,

Hugo


回答1:


Instead of

.attr({'text-anchor': 'end'});

before the rotation, use this one to align the text at its start

.attr({'text-anchor': 'start'});

MDN docu for text-anchor



来源:https://stackoverflow.com/questions/12952454/in-raphaeljs-how-to-align-rotated-text-to-the-bottom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!