I've created a form with an input, but the box only handles text in a single row. I would like to style it so that the input field is similar to that of Twitter's, where the box itself is multiple rows:
And it also expands when you hit enter:
This is currently what I have:
<form name="userForm">
<input type="text" id="userInput" name="userInput" placeholder="Enter text here.">
<button type="submit" id="button">Submit</button>
</form>
I've styled the button and the input, but haven't done anything to change its shape, so it's at default. What do I have to tweak to achieve this?
Use TextArea.Alter rows and columns attribute according to requirement.
To add the hover effect and change the box size , use css. Assign a normal height and width, and change that on focus.
Use
<div contenteditable="true">
(supported well) with storing to<input type="hidden">
.HTML:
js (using jQuery):
if anyone wanted to use this for wrapping a single line and using enter to submit or move on in the form, here is what to add:
You need to use an HTML
<textarea>
element.From MDN:
Using
<input>
for multiline text is not possible natively and, if hacked, would be invalid HTML.HTML5 spec:
Twitter input box
You mention you want the textarea to resemble Twitter's (auto-resize / no scrollbar). Consider this option and the following SO posts: