Input Field, wrap text instead of extending horizontally

醉酒当歌 提交于 2019-12-12 08:17:32

问题


I have an input field, a user will write text inside but when the text is to long it just extends horizontally instead of dropping down vertically.

I tried:

overflow: hidden;
word-wrap: break-word;

and I had no luck. Any other suggestions on how to accomplish this?


回答1:


I think you should use a multiline input field as TextArea:

http://htmlhelp.com/reference/html40/forms/textarea.html

Sample code:

<textarea rows="10" cols="30"></textarea> 



回答2:


Xtian - You shouldn't have any restriction on where you need to use an <input> or a <textarea>. Just give the text area the same name that you would've used for the input and you'll be fine.

For example, I just replaced

<input type="text" name="reply" />

With

<textarea rows="1" cols="26" name="reply"></textarea>

Much better now.



来源:https://stackoverflow.com/questions/3251661/input-field-wrap-text-instead-of-extending-horizontally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!