适用于 FF、CH 和 IE 的解决方案
这就是我最终得到的结果,并且在不同的主要浏览器(FF、CH 和 IE)中运行良好。我在 IE8 中对其进行了测试,它可以正常工作,并且在 IE9 中也可以正常工作。因此,如果您自己需要它,这里供您将来参考:
- 我没有使用表格,而是使用浮动 DIV
- 每个单元格都是带有标题的单独 DIV
- 标题有旋转文本
旋转的文本在转换之前仍保留尺寸,因此最好将其包含在实际上为其提供垂直等效尺寸的不同元素中。这样其他内容流就不会中断。
这是简化的 HTML 代码:
<div class="head">
<div class="vert">Vertical text example</div>
</div>
和随附的 CSS:
.container .head
{
/* float your elements or inline-block them to display side by side */
float: left;
/* these are height and width dimensions of your header */
height: 10em;
width: 1.5em;
/* set to hidden so when there's too much vertical text it will be clipped. */
overflow: hidden;
/* these are not relevant and are here to better see the elements */
background: #eee;
margin-right: 1px;
}
.container .head .vert
{
/* line height should be equal to header width so text will be middle aligned */
line-height: 1.5em;
/* setting background may yield better results in IE text clear type rendering */
background: #eee;
display: block;
/* this will prevent it from wrapping too much text */
white-space: nowrap;
/* so it stays off the edge */
padding-left: 3px;
/* IE specific rotation code */
writing-mode: tb-rl;
filter: flipv fliph;
/* CSS3 specific totation code */
/* translate should have the same negative dimension as head height */
transform: rotate(270deg) translate(-10em,0);
transform-origin: 0 0;
-moz-transform: rotate(270deg) translate(-10em,0);
-moz-transform-origin: 0 0;
-webkit-transform: rotate(270deg) translate(-10em,0);
-webkit-transform-origin: 0 0;
}