本文介绍了最优雅的方式强制TEXTAREA元素换行,*不管空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Html Textarea元素只有在到达空格或制表符时才换行。这很好,直到用户键入一个loooooooooooooooooooo足够多的字。我正在寻找一种方法来严格执行换行符(例如:即使它导致looooooooooo \\\
ooooooooooong)。

Html Textarea elements only wrap when they reach a space or tab character. This is fine, until the user types a looooooooooooooooooooooong enough word. I'm looking for a way to strictly enforce line breaks (eg.: even if it results in "loooooooooooo \n ooooooooooong").

我发现最好的是,每个字母之后的宽度unicode空间,但这会中断复制和粘贴操作。任何人都知道更好的方法?

The best I've found is to add a zero-width unicode space after every letter, but this breaks copy and paste operations. Anyone know of a better way?

注意:我指的是textarea元素这里(即:一个行为类似于文本输入)

Note: I'm referring to the "textarea" element here (i.e.: the one that behaves similarly to a text input) - not just a plain old block of text.

推荐答案

CSS设置 word-wrap:break-word text-wrap:unrestricted 显示为CSS 3功能。祝你好运,找到一种方法,在当前的实现。

The CSS settings word-wrap:break-word and text-wrap:unrestricted appear to be CSS 3 features. Good luck finding a way to do this on current implementations.

这篇关于最优雅的方式强制TEXTAREA元素换行,*不管空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-20 18:06