简体   繁体   English

HTML - 如何将段落分成同样宽的行?

[英]HTML - How to have paragraph split into equally wide lines?

This is about basic HTML+CSS page rendering.这是关于基本的 HTML+CSS 页面渲染。

When a paragraph is too long to fit in one line, it occupies as much space as it can, then wraps, and again and so on.当一个段落太长而不能放在一行中时,它会尽可能多地占据空间,然后换行,依此类推。

I would like the line wrapping of my webpage to happen so that the resulting lines are as equal as possible.我希望我的网页发生换行,以便生成的行尽可能相等。

So instead of getting:所以,而不是得到:

wrap wrap wrap wrap wrap包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包

wrap wrap wrap wrap wrap包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包

wrap wrap wrap wrap wrap包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包包

wrap

with a very short last line, I would get:最后一行很短,我会得到:

wrap wrap wrap wrap包裹包裹包裹包裹

wrap wrap wrap wrap包裹包裹包裹包裹

wrap wrap wrap wrap包裹包裹包裹包裹

wrap wrap wrap wrap包裹包裹包裹包裹

with more balanced lines.线条更平衡。 This would be useful, for instance, for right-justified quotations that may or may not be wrapped, but look ugly when wrapped by just a little.这将很有用,例如,对于可能会或可能不会被包裹的右对齐引用,但如果只包裹一点则看起来很丑陋。

So I'm looking for a HTML/CSS command that tells the browsers to do this.所以我正在寻找一个 HTML/CSS 命令来告诉浏览器这样做。

Remark : I'm not looking for the text to be justified.备注:我不是在寻找合理的文本。 What I need is the lines to be wrapped in a way that they have roughly equal size rather than the last one being much shorter.我需要的是将线条以大致相同的尺寸包裹起来,而不是最后一条更短。

Is it possible?是否有可能?

You might try fmt or par :您可以尝试fmtpar

fmt -w 80 input.txt

or要么

par 80jl < input.txt

Another option would be to use the justify.vim Vim script.另一种选择是使用justify.vim Vim 脚本。

Try out the following css statement: text-align:justify;试试下面的 css 语句: text-align:justify;

or see the different options in action here .在此处查看不同的选项

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM