Home >Web Front-end >CSS Tutorial >How Can I Vertically Rotate Text with Cross-Browser Compatibility?

How Can I Vertically Rotate Text with Cross-Browser Compatibility?

Linda Hamilton
Linda HamiltonOriginal
2024-12-09 22:44:11988browse

How Can I Vertically Rotate Text with Cross-Browser Compatibility?

Rotating Text Vertically with Cross-Browser Support

Need to display a single word vertically? This can be achieved with CSS, ensuring compatibility across major browsers such as IE6, Firefox 2, and Chrome.

Solution:

To rotate text 90 degrees using CSS, follow these steps:

  1. Define a class with the desired CSS transformations:
.rotate {
  transform: rotate(-90deg);
  -webkit-transform: rotate(-90deg);
  -moz-transform: rotate(-90deg);
  -ms-transform: rotate(-90deg);
  -o-transform: rotate(-90deg);

  transform-origin: 50% 50%;
  -webkit-transform-origin: 50% 50%;
  -moz-transform-origin: 50% 50%;
  -ms-transform-origin: 50% 50%;
  -o-transform-origin: 50% 50%;
}
  1. Apply the class to the desired text:
<span>

For Older Browsers:

In older browsers, you can use the following code for matrix transform:

.rot-neg-90 {
  -moz-transform: rotate(270deg);
  -moz-transform-origin: 50% 50%;
  -webkit-transform: rotate(270deg);
  -webkit-transform-origin: 50% 50%;
}

This will rotate the text -90 degrees in Firefox 3.5 and Safari/WebKit 3.1. IE has limited matrix support, but it's more complex to implement.

The above is the detailed content of How Can I Vertically Rotate Text with Cross-Browser Compatibility?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn