Home > Web Front-end > CSS Tutorial > How Can I Display Vertical Text in Table Headers with Dynamic Height and No Overflow?

How Can I Display Vertical Text in Table Headers with Dynamic Height and No Overflow?

Barbara Streisand
Release: 2024-11-15 19:08:02
Original
226 people have browsed it

How Can I Display Vertical Text in Table Headers with Dynamic Height and No Overflow?

Displaying Vertical Text in Table Headers with Dynamic Height and No Overflow

To display rotated text as table headers using the CSS transform property, there's a challenge of preventing rotated text from overflowing when the header row needs to adjust its height.

Problem:

When using the CSS transform property:

transform: rotate(-90deg);
Copy after login

to rotate the header text, the header row remains at its original height, causing the overflow of rotated text:

[Image of wrong example]

Solution:

To allow the header row to grow as needed, use the CSS property:

writing-mode: vertical-lr;
Copy after login

Explanation:

writing-mode controls the writing direction of the text. The value vertical-lr indicates that the text should be written vertically from left to right. This ensures that the rotated text fits within the vertical space of the header cell, allowing the header row to adjust its height accordingly.

[Image of correct example]

Example Code:

th {
  writing-mode: vertical-lr;
  transform: rotate(-90deg);
}
Copy after login

The above is the detailed content of How Can I Display Vertical Text in Table Headers with Dynamic Height and No Overflow?. 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