2010-08-06 69 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文本旋转。