Div uses textarea to make height adaptive, divtextarea

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.