Using CSS to Rotate Text and Adjust Cell Size in HTML Tables
When attempting to rotate text in table cells, it's important to also consider the impact on the cell size. As illustrated in the provided example, when using CSS transforms to rotate text without adjusting the cell size, the result can be distorted.
To resolve this issue, adjustments to the table and cell styles are necessary. By setting vertical-align: bottom and text-align: center for table headers (th), the text is positioned correctly after rotation.
For Chrome specifically, it's necessary to wrap the rotated text within a element. This ensures that the text's direction is also changed, preventing horizontal text from appearing after rotation. The span element is subsequently styled with -ms-writing-mode: tb-rl, -webkit-writing-mode: vertical-rl, writing-mode: vertical-rl, transform: rotate(180deg), and white-space: nowrap.
Example Code
<code class="css">th { vertical-align: bottom; text-align: center; } th span { -ms-writing-mode: tb-rl; -webkit-writing-mode: vertical-rl; writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }</code>
<code class="html"><table> <tr> <th><span>Rotated text by 90 deg.</span></th> </tr> </table></code>
By implementing these style adjustments, it becomes possible to rotate text by 90 degrees while maintaining proper cell size and formatting.
The above is the detailed content of How to Rotate Text in HTML Tables Without Distorting Cell Size?. For more information, please follow other related articles on the PHP Chinese website!

There's been a run of tools, articles, and resources about color lately. Please allow me to close a few tabs by rounding them up here for your enjoyment.

Robin has covered this before, but I've heard some confusion about it in the past few weeks and saw another person take a stab at explaining it, and I wanted

I absolutely love the design of the Sandwich site. Among many beautiful features are these headlines with rainbow underlines that move as you scroll. It's not

Many popular resume designs are making the most of the available page space by laying sections out in a grid shape. Let’s use CSS Grid to create a layout that

Page reloads are a thing. Sometimes we refresh a page when we think it’s unresponsive, or believe that new content is available. Sometimes we’re just mad at

There is very little guidance on how to organize front-end applications in the world of React. (Just move files around until it “feels right,” lol). The truth

Most of the time you don’t really care about whether a user is actively engaged or temporarily inactive on your application. Inactive, meaning, perhaps they

Wufoo has always been great with integrations. They have integrations with specific apps, like Campaign Monitor, Mailchimp, and Typekit, but they also


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Chinese version
Chinese version, very easy to use

WebStorm Mac version
Useful JavaScript development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft