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
Release: 2024-12-09 22:44:11
Original
990 people have browsed it

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%;
}
Copy after login
  1. Apply the class to the desired text:
<span>
Copy after login

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%;
}
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template