创建以垂直方向文本作为表头的 HTML 表格
我想创建一个 HTML 表格,其中垂直书写的文本作为标题(即标题文本旋转 90 度)。我正在使用以下样式,
<th style="-webkit-transform:rotate(90deg); writing-mode:tb-rl; -moz-transform:rotate(90deg); -o-transform: rotate(90deg); white-space:nowrap; display:blocking; padding-left:1px;padding-right:1px;padding-top:10px;padding-bottom:10px; " align="left" id="#COLUMN_HEADER_NAME#">#COLUMN_HEADER#</th>
在 MS IE 9.x 中显示正常。在 Firefox 和 Chrome 中,标题似乎漂浮在表格顶部,它与其下方的表格行重叠。有人可以帮忙吗?我只是不知道为什么会发生这种情况。我从本教程开始: http://scottgale.com/blog /css-vertical-text/2010/03/01/
TIA,塔马斯
I would like to create a HTML table with vertically written text as header (i.e. header text is rotated 90 degrees). I am using the flollowing style
<th style="-webkit-transform:rotate(90deg); writing-mode:tb-rl; -moz-transform:rotate(90deg); -o-transform: rotate(90deg); white-space:nowrap; display:blocking; padding-left:1px;padding-right:1px;padding-top:10px;padding-bottom:10px; " align="left" id="#COLUMN_HEADER_NAME#">#COLUMN_HEADER#</th>
In MS IE 9.x is displays OK. In Firefox and Chrome the header seems to float over the top of the table, it overlaps with the table rows below it. can somebody please help? I simple have no idea why is this happening. I started out with this tutorial: http://scottgale.com/blog/css-vertical-text/2010/03/01/
TIA, Tamas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不相信单独使用 CSS 旋转内容时可以改变
的高度。下面是我如何使用一些 jQuery 来做到这一点。
http://jsfiddle.net/tsYRQ/1004/
I don't believe you can get the height of the
<th>
to change when rotating it's contents with CSS alone. Below is how I do this with a bit of jQuery.http://jsfiddle.net/tsYRQ/1004/
来自 http://blog.petermares.com/2010/10/27/vertical-text-in-html-table-headers-for-webkitmozilla-browsers-without-using-images/
使用 CSS 旋转
元素内的元素(例如
)会导致列宽缩小到刚好可以容纳旋转的文本 - 但是行高不会根据需要增长。
适用于 Mac 上的 Chrome 和 Safari(至少对我来说)。
From http://blog.petermares.com/2010/10/27/vertical-text-in-html-table-headers-for-webkitmozilla-browsers-without-using-images/
Using CSS to rotate an element (e.g. a
<div>
) within a<td>
element causes the column width to shrink to just accomodate the rotated text - however the row height does not grow as needed.Works in Chrome and Safari on Mac (for me at least).
我认为有一种更简单的方法可以在表格单元格中获取垂直文本:
I think there is an easier way to get vertical text in table cell:
只需使用 CSS 即可完成
simply you can do it with CSS