如何在textarea中保持word始终在同一行

时间:2015-05-27 05:52:21

标签: html css textarea line-breaks

所以我有400px * 200px textarea包含像“so-me-thing”这样的词。结果如下:

| This is so-me text with syl-lab- |
| les. I want the word syl-lab-les |
| to be on the same line.          |

我想要的是:

| This is so-me text with          |
| syl-lab-les. I want the word     |
| syl-lab-les to be on the same    |
| line.                            |

我不知道如何实现这一目标。希望有人理解我想要解释的内容。我需要纯粹的CSS解决方案,而不是javascript或其他。

3 个答案:

答案 0 :(得分:2)

您需要使用

word-break: keep-all;

如果你想要反对那么

word-break: break-all;

答案 1 :(得分:0)

使用CSS word-break: break-word;属性,然后尝试。

答案 2 :(得分:0)

如何使用:

textarea{
    white-space: pre;
    word-wrap: normal;
}