【问题标题】:How to keep word always in the same line in textarea如何在textarea中始终保持单词在同一行
【发布时间】:2015-08-09 01:11:45
【问题描述】:

所以我有这个 400px * 200px 的文本区域,其中包含“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 或其他。

【问题讨论】:

标签: html css textarea line-breaks


【解决方案1】:

你需要使用

word-break: keep-all;

如果你想要相反的话

word-break: break-all;

【讨论】:

    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      如何使用:

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

      【讨论】:

        猜你喜欢
        • 2013-12-22
        • 1970-01-01
        • 2021-06-19
        • 1970-01-01
        • 2012-10-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-06-24
        相关资源
        最近更新 更多