如何在 CSS 中使文本从上到下运行?

发布于 2024-07-13 13:01:21 字数 107 浏览 5 评论 0原文

有谁知道如何使 div 中的文本从上到下对齐。

所以甚至不让我演示它。 。 。 我只是希望这些字母在页面上垂直排列,就像建筑物的故事一样。 希望我不需要用图像来做。

Does anyone know how to make text align top-to-bottom in a div.

SO won't even let me demonstrate it . . . I just want the letters to stack on top of each other in a vertical line down the page like the stories of a building. Was hoping I didn't need to do it with an image.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

不喜欢何必死缠烂打 2024-07-20 13:01:21

让文本沿垂直线排列,无需修改

writing-mode

CSS writing-mode 属性 让您的文本垂直排列。

.traditional-vertical-writing
{
  writing-mode: vertical-rl;
}
<p class="traditional-vertical-writing">
  This text runs vertically.<br>
  『只是』 ((but the thing is)),since Latin alphabets are not for vertical writing,
  not only the lines but each of the non-vertical-writing letters also gets rotated.<br>
  0123456789
</p>


text-orientation

如果您不希望非垂直书写的字母在垂直方向上旋转,您可以使用 CSS text-orientation 属性

.vertical-writing
{
  writing-mode: vertical-rl;
  text-orientation: upright;
}
<p class="vertical-writing">
  This text runs vertically.<br>
  『それに』 ((and in addition))、now you don't have to turn your head 90 degrees clockwise
  to read these non-vertical-writing letters!<br>
  0123456789
</p>


如果你想做一些tate-chuu-yoko[1][2][3] (縦中横;垂直书写时有点水平书写),

考虑使用 text-combine-upright

Having your text run along vertical lines WITHOUT HACKS

writing-mode

CSS writing-mode attribute lets your text run vertically.

.traditional-vertical-writing
{
  writing-mode: vertical-rl;
}
<p class="traditional-vertical-writing">
  This text runs vertically.<br>
  『只是』 ((but the thing is)),since Latin alphabets are not for vertical writing,
  not only the lines but each of the non-vertical-writing letters also gets rotated.<br>
  0123456789
</p>


text-orientation

If you don't want non-vertical-writing letters to rotate themselves in vertical lines, you may use CSS text-orientation attribute as well.

.vertical-writing
{
  writing-mode: vertical-rl;
  text-orientation: upright;
}
<p class="vertical-writing">
  This text runs vertically.<br>
  『それに』 ((and in addition))、now you don't have to turn your head 90 degrees clockwise
  to read these non-vertical-writing letters!<br>
  0123456789
</p>


And if you’re to do some tate-chuu-yoko[1][2][3] (縦中横; a bit of horizontal writing while writing vertically),

consider using text-combine-upright.

感情洁癖 2024-07-20 13:01:21

要使字母从上到下同时保持其正常方向,如下所示:

F

O

O

HTML:

<div class="toptobottom">letters</div>

CSS:

.toptobottom{
  width: 0;
  word-wrap: break-word;
}

自动换行允许单词在中间断开,因此这将使字母从上到下。 它也得到了很好的支持: https://developer.mozilla.org/en -US/docs/CSS/自动换行

To make the letters top-to-bottom while keeping their normal orientation, like this:

F

O

O

HTML:

<div class="toptobottom">letters</div>

CSS:

.toptobottom{
  width: 0;
  word-wrap: break-word;
}

word-wrap allows words to be broken in the middle, so this will make the letters top-to-bottom. It's also really well supported: https://developer.mozilla.org/en-US/docs/CSS/word-wrap

柠北森屋 2024-07-20 13:01:21

Html:

<div class="bottomtotop">Hello!</div>

CSS:

.bottomtotop { transform:rotate(270deg); }

Html:

<div class="bottomtotop">Hello!</div>

Css:

.bottomtotop { transform:rotate(270deg); }
扬花落满肩 2024-07-20 13:01:21

这是我使用过的,它对我有用:

CSS

.traditional-vertical-writing
 {
   writing-mode: vertical-rl;
   transform:rotate(180deg);
 }

HTML,记住将文本放在

标签

<th rowspan="2" class="text-sm"><p class="traditional-vertical-writing">S/N</p></th>

结果 中
输入图片此处描述

This is what I have used and it works for me:

CSS

.traditional-vertical-writing
 {
   writing-mode: vertical-rl;
   transform:rotate(180deg);
 }

HTML, Remember to put your text in

tag

<th rowspan="2" class="text-sm"><p class="traditional-vertical-writing">S/N</p></th>

RESULTS
enter image description here

聊慰 2024-07-20 13:01:21

NJCodeMonkey 的答案很接近。

对我来说,我必须使用 word-break 。 它与 word-wrap:break-word; 有点不同

所以它看起来像这样。

HTML:

<div class="VerticalText">LongTextWithNoSpaces</div>

CSS:

.VerticalText
{
   width: 1px;
   word-break: break-all;
}

这在 Firefox 24、IE 8 和 IE 11 中对我有用。

NJCodeMonkey's answer was close.

For me I had to use word-break. It's a little different from word-wrap:break-word;

So it would look like this.

HTML:

<div class="VerticalText">LongTextWithNoSpaces</div>

CSS:

.VerticalText
{
   width: 1px;
   word-break: break-all;
}

This worked for me in Firefox 24, IE 8 and IE 11.

花开雨落又逢春i 2024-07-20 13:01:21

根据您的字体大小进行相应调整:

<div style='width:12px'>a b c d</div>

Depending on your font size, adjust accordingly:

<div style='width:12px'>a b c d</div>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文