Using display: flex
solves many problems, however, I can't create some auto-resizing textarea with it, but it works with <div contenteditable="true"></div>
. I want to know why it doesn't work with textarea
and if there's another way to solve this without using Javascript.
HTML with <div contenteditable="true">
:
<div id="flex">
<div id="space"></div>
<div contenteditable="true"></div>
</div>
HTML with <textarea>
:
<div id="flex">
<div id="space"></div>
<textarea></textarea>
</div>
CSS for both:
#flex {
display: flex;
height: 90vh;
background-color: #f99;
flex-direction: column;
}
#space {
background-color: #ff9;
flex: 2;
}
textarea,
div[contenteditable="true"] {
min-height: 30px;
max-height: 50vh;
overflow: auto;
resize: none;
}