I'm trying to move excess text to a new line when there's no more space in the first line. But my text just keep on filling in the same line without moving to another line. How can i fix this? I want to move to the next line when text is filled in the first line.
I already tried
word-wrap: break-word
white-space: initial;
But to no effect.
My code is like below:
<form onSubmit={ handleSubmit }>
<div className="create_post_div unchange_div">
<Field
name="askQuestionInput"
component="input"
type="text"
className="post_input_preview unchange_div"
placeholder="Ask your question here"
/>
</div>
</form>
My css classes:
.create_post_div{
width: 100%;
margin-top: 10px;
margin-bottom: 10px;
padding: 10px;
}
.post_input_preview {
width: 640px;
border: none;
margin-bottom: 10px;
font-size: 16px;
outline: none;
}
Thanks in advance.
By default, pressing Enter or Shift and Enter will generate a new line for a textarea element.
Thankfully, there is a keyboard shortcut that moves to the next line. Move the text cursor to where you want the new line to begin, press the Enter key, hold down the Shift key, and then press Enter again.
<br>: The Line Break element. The <br> HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division of lines is significant.
HTML input elements won't wrap in the way that you're describing. See here.
You can however change your input type=['text']
to a textarea
, and as a user types, the text will wrap onto the next line. See this answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With