When working with the CSS style writing-mode: vertical-lr;
and two different languages font, my text would get aligned to the left side of the kanji on Chrome, but to the right side on Firefox.
This code snippet that I’m working with:
<h1 style="writing-mode: vertical-lr;">
結ꦲꦂꦠꦤ꧀ꦠ
</h1>
How can I modify my code it so it can be similar to the Chrome counterpart, where the script text is horizontally aligned to the left side of the kanji, and to be consistent across browsers?
2
Answers
To achieve consistent horizontal alignment of text across different browsers when using writing-mode: vertical-lr;, you can use additional CSS properties to control the alignment. Specifically, you can use the text-align and text-orientation properties to ensure that the text aligns as desired.
結ꦲꦂꦠꦤ꧀ꦠ
text-align: start;:This property ensures that the text aligns to the start of the line, which in the case of vertical text, means aligning to the top of the container. This helps maintain consistent alignment across different browsers.
Unfortunately, inconsistent alignment problems are not uncommon, especially when using vertical text and different alphabets.
If you discover language specific issues please file a bug-report.
A possible workaround could be to wrap each language in a separate
<span>
element and tweak the baseline position viaascent-override
.In the above example I’m setting a custom ascent value only for the Javanese unicode range