Wrapping text inside input type=“text” element HTML/CSS

后端 未结 4 826
遇见更好的自我
遇见更好的自我 2020-11-30 06:11

The HTML shown below,


is displayed in a browser like so:

4条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 06:53

    That is the textarea's job - for multiline text input. The input won't do it; it wasn't designed to do it.

    So use a textarea. Besides their visual differences, they are accessed via JavaScript the same way (use value property).

    You can prevent newlines being entered via the input event and simply using a replace(/\n/g, '').

提交回复
热议问题