How do I make text spanning multiple lines each have each letter vertically aligned in CSS?

ctrlqc 注册会员
2023-01-24 23:42

If using a monospace font isn't possible then one way would be to wrap each character in a span element and force that to have a fixed width and the character to be centered within it.

Not very elegant and you'd want to employ some preprocessing rather than do it by hand - could be done fairly simply in Javascript.

Here's a trivial snippet with a couple of wide characters and a narrow one to show the idea:

span {
  width: 24px;
  display: inline-block;
  text-align: center;
A i

About the Author

Question Info

Publish Time
2023-01-24 23:42
Update Time
2023-01-24 23:42