Div uses textarea to make height adaptive, divtextarea
Today, I am a bit speechless. I found a lot of code on Baidu about textarea and input highly adaptive. I also thought about how to judge the scroll bar of textarea and dynamically change its height, until I searched for this method that made me stare at my dog ......
<Div class = "test_box" contenteditable = "true"> <br/> </div>
I feel this sentence ...... It's all
Contenteditable: Specifies whether to edit the content of an element.
Attribute Value: true: indicates an editable element;
False: indicates that the element cannot be edited;
Classname: contenteditable that inherits the parent element.
With this attribute, editable tags are no longer input and textarea, and p and div elements can be edited.
Next, we only need to set the width and minimum height of the div to achieve self-adaptation. Of course, you need to add a border for the div so that we cannot find it.
This makes me deeply feel the importance of learning and using it.