Currently, the contenteditable
attribute is being utilized on the <div>
tag to enable autogrow functionality similar to a textbox. Additionally, there is an attempt to incorporate a height transition. While most aspects are functioning correctly, there is one issue - the animated height adjustment does not occur when deleting characters, specifically a line, unlike when adding new lines. My CSS knowledge is still limited.
.autogrow {
border: 1px solid rgb( 0, 0, 0 );
padding: 10px;
}
@keyframes line_insert {
from {
height: 0px;
}
to {
height: 20px;
}
}
.autogrow[contenteditable] > div {
animation-duration: 250ms;
animation-name: line_insert;
}
.autogrow[contenteditable] {
overflow: hidden;
line-height: 20px;
}
<div class="autogrow" contenteditable="true"></div>
When attempting to animate using Shift + Enter, it does not work; however, it functions correctly when only using Enter. The challenge lies in deleting lines and using the Shift + Enter combination to enter a new line.
How can this be resolved? Is there a way to achieve this using purely CSS, or would it require implementing a JavaScript function?