I am learning CSS. I have a div which contains a flexible textarea. Now I want the textarea and outer div to auto expand height when the user inputs multiline content in the textarea, and when the textarea is more than 3 rows, stop the expand and scroll the textarea. How should I write the CSS?
Rendered Code:
.outerdiv {
height: auto;
display: flex;
}
.outerdiv textarea {
height: 100%;
flex-grow: 1;
}
<div class="outerdiv">
<textarea></textarea>
</div>
2
Answers
I don’t think there is a css solution.
However this JS kinda does what you want:
It does not make the texarea smaller when removing text. But it does grow when you type.
You could adapt this absolute gem of an answer as follows: