So, I'm having trouble now with the text area, I can't resize it to the content width... I found a long and detailed answer about content height and it works! But there is no content width above...
This is that article: Creating a text area with automatic resizing
However, my problem is not solved, I need to adjust the width too. Consider maximum and minimum widths.
This is sample code:
$("textarea").each(function () { this.setAttribute("style", "height:" (this.scrollHeight) "px;"); }).on("input", function () { this.style.height = 0; this.style.height = (this.scrollHeight) "px"; }); $("textarea").trigger("input");
textarea{ border: 1px solid black; min-width: 50px; max-width: 300px; width: auto; }