http://jsfiddle.net/t5GgE/1/
指定標頭點(65,60)的轉換原點,不允許換行並使td
居中對齊。
th.rotate {
white-space: nowrap;
-webkit-transform-origin: 65px 60px;
-moz-transform-origin: 65px 60px;
-o-transform-origin: 65px 60px;
-ms-transform-origin: 65px 60px;
transform-origin: 65px 60px;
}
td.rights {
text-align: center;
}
更新IE8及以下
對於IE8和下面你不得不使用Transformation matrices而不是rotate(270deg)
。 所以,270deg的對應旋轉矩陣是[0, 1, -1, 0]
。
你需要做的,是添加以下和應該只是罰款IE8及以下:
th.rotate span {
/* rotated text in IE renders very bad (unless you use clear type), so that even by making it normal, looks less bold but still bold */
font-weight: normal\9; /* \9 is an hack for IE8 and below */
letter-spacing: 3px\9; /* because is so bold, need to give letters some space to breath */
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0, M12=1, M21=-1, M22=0, SizingMethod = "auto expand");
width: 150px\9;
height: 150px\9;
margin-right: -130px\9;
}
Final jsFiddle version
IE9的問題和解決方法 在IE9中,你會在標題部分看到一個黑色的大矩形,這個錯誤的原因是IE9識別出-ms-transform
和filter
。當兩個CSS都存在時,瀏覽器只會渲染一個黑色區域。爲了解決這個問題,我強制你使用IE9的條件包含來僅使用-ms-transform
。
[垂直旋轉HTML表格標題單元格內的文本](http://stackoverflow.com/questions/7076052/vertically-rotate-text-inside-an-html-table-header-cell)。 – Vucko 2013-02-21 12:57:51
是的,我明白這一點。但它不起作用。你能偷看我的jsfiddle @Vucko嗎? – 2013-02-21 12:59:37
@ H.Ferrence檢查我更新的答案以支持IE。 – 2013-02-22 11:33:55