如何对齐表格中的旋转文本?
我找到了如何将文本旋转 90°(感谢 SO),问题是文本是垂直渲染的,但(我猜)框是水平计算的(如旋转之前)。
我有包含此类旋转文本的表格单元格,我想将文本对齐单元格顶部。结果我得到这样的结果:
旋转前的文本:
rotated90
旋转后的文本(请原谅我的 ASCII 屏幕截图):
0
9
d
e
t
a
t
o
r
旋转的文本与单元格顶部对齐:
0
9
d
e
-----------
t
a
t
o
r
所以部分文本实际上位于单元格上方,这很糟糕。
期望的效果:
-----------
0
9
d
e
t
a
t
o
r
问题:如何垂直对齐文本,即如何使浏览器看到旋转后(而不是旋转前)的框?
I found out how to rotate the text (thanks to SO) by 90°, the problem is the text is rendered vertically, but (I guess) the box is calculated horizontally (as before rotating).
I have table cell which contains such rotated text, and I would like to align the text at top of the cell. As the result I get something like this:
Text before rotation:
rotated90
Text after rotation (please excuse my ASCII screenshot):
0
9
d
e
t
a
t
o
r
Rotated text aligned to top of the cell:
0
9
d
e
-----------
t
a
t
o
r
So part of the text is above the cell actually, which is bad.
Desired effect:
-----------
0
9
d
e
t
a
t
o
r
QUESTION: how to align text vertically, i.e. how to make browser see the box as after (not before) rotattion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果不指定旋转文本所在的单元格的高度,这似乎是不可能的。Webkit
/Mozilla 在元素的显示上执行旋转,而不是在其框模型上执行旋转。
CSS3 属性
writing-mode
在 IE 中可以正常工作,旋转盒子模型。这个属性应该是大多数浏览器都支持的,但是我看的文章说当时只有IE支持。It doesn't look like this is possible without specifying the height of the cell that the rotated text is in.
Webkit/Mozilla performs the rotation on the element's display, but not its box model.
The CSS3 property
writing-mode
works properly in IE, rotating the box model. This property should be supported by most browsers, but the article I read said it was only supported by IE at the time.