简体   繁体   English

如何使用html5 canvas创建垂直表标题文本?

[英]how to create vertical table heading text with html5 canvas?

Does anyone know if it's possible to create vertical text in a html5 canvas and then have the canvas resize to the content? 有谁知道是否有可能在html5画布中创建垂直文本,然后将画布调整为内容大小?

I've seen posts about adding text and rotating it but don't know how to have the canvas resize automatically to it afterwards. 我看过有关添加文本和旋转文本的文章,但不知道如何在随后自动调整画布的大小。

Here is a link to a page with one of the tables: here 这是带有其中一个表的页面的链接: 这里

I basically want to replace the top headings with vertical text in different canvases. 我基本上想用不同画布中的垂直文本替换顶部标题。 The team names need to be dynamic and I'd rather not have them generated as jpg's. 团队名称必须是动态的,我宁愿不要将它们生成为jpg。

Thanks! 谢谢!

有可能,请参见快速提琴: http : //jsfiddle.net/dev_null_dweller/qyfyb/

It's possible though tricky to rotate text with CSS3 Transform : http://jsfiddle.net/PhilippeVay/hXnsT/2/ 使用CSS3 Transform旋转文本可能很棘手: http : //jsfiddle.net/PhilippeVay/hXnsT/2/
Each text in header cell is in a span element. 标题单元格中的每个文本都在span元素中。 This span is constrained in width and the grand-parent (tr element, but it could be the th parent as well) has an height equal to this width. 此范围的宽度受到限制,祖父母(tr元素,但也可以是其父元素)的高度等于此宽度。
Text could be rotated in IE8 and below as well with the help of the writing-mode property but the text in the larger first column needs to be moved specifically in IE. 文本也可以在IE8和更低版本中借助writing-mode 属性进行旋转,但是较大的第一列中的文本需要在IE中专门移动。

Beside this, header cells were tagged with th elements (with scope attribute for better accessibility) rather than td elements with .heading class. 除此之外,标头单元还用th元素(具有scope属性以提供更好的可访问性)而不是带有.heading类的td元素.heading

In then end I re-wrote it so it did exactly what I wanted and it's at http://wncba.co.uk/results/javascript/vertical-text.js if anyone wants to use it. 最后,我重新编写了它,使其完全符合我的要求,如果有人想使用它, 请访问http://wncba.co.uk/results/javascript/vertical-text.js

Here is a page that shows it working: http://wncba.co.uk/results/?action=navigate&season=2012&league_id=2&division_id=7&nav_key=4e16159770efb07ac6e6bae4f86c7dc5 这是显示其工作原理的页面: http : //wncba.co.uk/results/?action= navigate& season= 2012& league_id=2&division_id=7&nav_key=4e16159770efb07ac6e6bae4f86c7dc5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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