One of my skills includes creating a dynamic contenteditable
span within text that can expand and contract, as well as wrap around multiple lines without taking up the entire width:
div {
width: 100px;
background: #f00;
padding: 5px;
}
span {
border: 1px solid #000;
}
<div>
<span contenteditable="true">Type Something</span>
</div>
I understand the difficulties and complexities associated with using contenteditable
and prefer plain text. In order to achieve this, I am interested in using an <input type="text">
. Is there a way to apply CSS/JS to make it function in a similar manner without having to simulate it programmatically with multiple input fields?
Explanation
A textarea
is set to display: inline-block
, however, setting it as inline does not truly replicate the behavior of an inline element like a span. Therefore, it does not serve as the alternative solution I am seeking.