2010-08-06 70 views
1

如何在PHP中使用垂直文本?垂直文本顯示在表TD中?

我需要的文字在表TD 文本

顯示在垂直形式應該打印垂直或我需要它旋轉?

+1

php有什麼與它有關的? – 2010-08-06 19:52:02

+1

你的意思是用PHP渲染一個帶有垂直文本的圖形? PHP不處理文本顯示,你需要像在[這個問題]中使用CSS(http://stackoverflow.com/questions/1080792/how-to-draw-vertical-text-with-css-cross-瀏覽器) – 2010-08-06 19:52:29

+1

你只是想讓這些字母出現在對方之上嗎?或者你還想讓字母旋轉90度(或270度)? – 2010-08-06 19:52:29

回答

5

CSS:

對於FF 3.5或Safari/3.1的Webkit,檢查出:-moz-transform(和-webkit變換)。 IE有Matrix filter(v5.5 +)。

.rot-neg-90 { 
    /* rotate -90 deg, not sure if a negative number is supported so I used 270 */ 
    -moz-transform: rotate(270deg); 
    -moz-transform-origin: 50% 50%; 
    -webkit-transform: rotate(270deg); 
    -webkit-transform-origin: 50% 50%; 
    /* IE support too convoluted for the time I've got on my hands... */ 
} 

PHP:由於OP已標記的PHP

但是如果你的意思是在圖像上垂直文本,請嘗試:

header ("Content-type: image/png"); 

// imagecreate (x width, y width) 
$img_handle = @imagecreatetruecolor (15, 220) or die ("Cannot Create image"); 

// ImageColorAllocate (image, red, green, blue) 
$back_color = ImageColorAllocate ($img_handle, 0, 0, 0); 
$txt_color = ImageColorAllocate ($img_handle, 255, 255, 255); 
ImageStringUp ($img_handle, 2, 1, 215, $_GET['text'], $txt_color); 
ImagePng ($img_handle); 
ImageDestroy($img_handle); 
1

假設您希望您的輸出爲實際文本而不是圖形,則需要使用CSS文本旋轉。文本旋轉目前不是標準的一部分(儘管CSS3應該改變這一點),並且通常通過特定於瀏覽器的前綴(用於webkit的-webkit-transform,用於Mozilla瀏覽器的-moz-transform)或文本過濾器(IE) 。

This article提供了一個很好的概述如何以跨瀏覽器的方式使用CSS文本旋轉。