テキストを書き込むと、textarea
のサイズが大きくなりますが、このテキストを削除すると何も起こりません。テキストを削除する場合、textarea
の高さを動的に減らすことは可能ですか?設定しテキストを削除した後のテキストエリアのサイズ変更
.OuterDiv
{
width:200px;
height:300px;
border:1px solid #000;
position:relative;
bottom:0;
}
.text
{
resize:none;
width:198px;
min-height:45px;
height:auto;
max-height:145px;
background-color:rgba(90,90,180,1);
font-size:16px;
font-family:Arial;
overflow-y:auto;
padding:0;
}
[contenteditable=true]:empty:before{
content: attr(placeholder);
display: block; /* For Firefox */
color: grey;
}
<div class="OuterDiv">
<div class="text" contentEditable="true" placeholder="Write some text..."></div>
</div>