Home > Web Front-end > CSS Tutorial > How to Orient Text Vertically on the Right in CSS?

How to Orient Text Vertically on the Right in CSS?

Barbara Streisand
Release: 2024-11-15 11:54:02
Original
883 people have browsed it

How to Orient Text Vertically on the Right in CSS?

How to Orient Text Vertically on the Right Using CSS

Can you align text vertically on the right in CSS? For example, you might want to display a date like "Sunday" upright but positioned on the right side of an element.

Problem:

You've tried using the following code, but it doesn't reverse the orientation:

div {
  writing-mode: vertical-rl;
  text-orientation: sideways;
}
Copy after login

Solution:

The sideways value isn't supported by all browsers. Instead, you can use a scale transformation to achieve the desired effect:

div {
  writing-mode: vertical-rl;
  /*text-orientation: sideways;*/
  transform:scale(-1);
}
Copy after login

This will flip the text horizontally, making it appear as if it's oriented vertically on the right.

Example:

<div>Sunday</div>
Copy after login

Output with Transformation:

|
|
| Dimanche
Copy after login

The above is the detailed content of How to Orient Text Vertically on the Right in CSS?. 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