简体   繁体   English

防止长文本溢出

[英]Prevent long text from overflowing

How do I break all words (inside the <pre> ) that are too long that keep overflowing:如何打破所有太长且不断溢出的单词(在<pre>内):

<pre>A paragraph is a group of words put together to form a group that is usually longer than a sentence. Paragraphs are often made up of several sentences. There are usually between three and eight sentences. Paragraphs can begin with an indentation (about five spaces), or by missing a line out, and then starting again. This makes it easier to see when one paragraph ends and another begins.</pre>

You can use word-wrap and white-space to achieve the desired results.您可以使用自动换行和空格来实现所需的结果。 Like this:像这样:

 pre { white-space: pre-wrap; word-break: break-word; }
 <pre>A paragraph is a group of words put together to form a group that is usually longer than a sentence. Paragraphs are often made up of several sentences. There are usually between three and eight sentences. Paragraphs can begin with an indentation (about five spaces), or by missing a line out, and then starting again. This makes it easier to see when one paragraph ends and another begins. </pre>

NOTE : I have used css on注意:我在上使用过 css element that sets white-space to pre-wrap and word-break to break-word .white-space设置为pre-wrap并将word-break设置为break-word的元素。

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

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