垂直文本显示在表TD中?

时间:2010-08-06 19:50:07

标签: html css

如何在PHP中使用垂直文本?

我需要在表Td中以垂直样式显示文本  文字

它应该打印垂直还是需要它旋转?

3 个答案:

答案 0 :(得分:5)

<强> CSS:

对于FF 3.5或Safari / Webkit 3.1,请查看:-moz-transform(和-webkit-transform)。 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 :(得分:4)

这与PHP没有任何关系。

只需使用正确的CSS属性

http://www.w3.org/TR/2001/WD-css3-text-20010517/#PrimaryTextAdvanceDirection

编辑:抱歉,我认为这是跨浏览器,但它看起来只适用于IE浏览器 您可以使用-webkit-transform: rotate(-90deg);-moz-transform: rotate(-90deg);来实现跨浏览器兼容性。

答案 2 :(得分:1)

假设您希望输出是实际文本而不是图形,则需要使用CSS文本旋转。文本轮换当前不是标准的一部分(尽管CSS3应该改变它),并且通常通过浏览器特定的前缀(webkit的-webkit-transform,Mozilla浏览器的-moz-transform)或文本过滤器(IE)支持。

This article提供了有关如何以跨浏览器方式使用CSS文本轮换的良好概述。

相关问题